1<?php
2
3namespace RainLoop\Plugins;
4
5class Property
6{
7	/**
8	 * @var string
9	 */
10	private $sName;
11
12	/**
13	 * @var string
14	 */
15	private $sLabel;
16
17	/**
18	 * @var string
19	 */
20	private $sDesc;
21
22	/**
23	 * @var int
24	 */
25	private $iType;
26
27	/**
28	 * @var bool
29	 */
30	private $bAllowedInJs;
31
32	/**
33	 * @var mixed
34	 */
35	private $mDefaultValue;
36
37	/**
38	 * @var string
39	 */
40	private $sPlaceholder;
41
42	private function __construct($sName)
43	{
44		$this->sName = $sName;
45		$this->iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
46		$this->mDefaultValue = '';
47		$this->sLabel = '';
48		$this->sDesc = '';
49		$this->bAllowedInJs = false;
50		$this->sPlaceholder = '';
51	}
52
53	/**
54	 * @param string $sName
55	 *
56	 * @return \RainLoop\Plugins\Property
57	 */
58	public static function NewInstance($sName)
59	{
60		return new self($sName);
61	}
62
63	/**
64	 * @param int $iType
65	 *
66	 * @return \RainLoop\Plugins\Property
67	 */
68	public function SetType($iType)
69	{
70		$this->iType = (int) $iType;
71
72		return $this;
73	}
74
75	/**
76	 * @param mixed $mDefaultValue
77	 *
78	 * @return \RainLoop\Plugins\Property
79	 */
80	public function SetDefaultValue($mDefaultValue)
81	{
82		$this->mDefaultValue = $mDefaultValue;
83
84		return $this;
85	}
86
87	/**
88	 * @param string $sPlaceholder
89	 *
90	 * @return \RainLoop\Plugins\Property
91	 */
92	public function SetPlaceholder($sPlaceholder)
93	{
94		$this->sPlaceholder = $sPlaceholder;
95
96		return $this;
97	}
98
99	/**
100	 * @param string $sLabel
101	 *
102	 * @return \RainLoop\Plugins\Property
103	 */
104	public function SetLabel($sLabel)
105	{
106		$this->sLabel = $sLabel;
107
108		return $this;
109	}
110
111	/**
112	 * @param string $sDesc
113	 *
114	 * @return \RainLoop\Plugins\Property
115	 */
116	public function SetDescription($sDesc)
117	{
118		$this->sDesc = $sDesc;
119
120		return $this;
121	}
122
123	/**
124	 * @param bool $bValue = true
125	 * @return \RainLoop\Plugins\Property
126	 */
127	public function SetAllowedInJs($bValue = true)
128	{
129		$this->bAllowedInJs = !!$bValue;
130
131		return $this;
132	}
133
134	/**
135	 * @return string
136	 */
137	public function Name()
138	{
139		return $this->sName;
140	}
141
142	/**
143	 * @return bool
144	 */
145	public function AllowedInJs()
146	{
147		return $this->bAllowedInJs;
148	}
149
150	/**
151	 * @return string
152	 */
153	public function Description()
154	{
155		return $this->sDesc;
156	}
157
158	/**
159	 * @return string
160	 */
161	public function Label()
162	{
163		return $this->sLabel;
164	}
165
166	/**
167	 * @return int
168	 */
169	public function Type()
170	{
171		return $this->iType;
172	}
173
174	/**
175	 * @return mixed
176	 */
177	public function DefaultValue()
178	{
179		return $this->mDefaultValue;
180	}
181
182	/**
183	 * @return string
184	 */
185	public function Placeholder()
186	{
187		return $this->sPlaceholder;
188	}
189
190	/**
191	 * @return array
192	 */
193	public function ToArray()
194	{
195		return array(
196			 '',
197			 $this->sName,
198			 $this->iType,
199			 $this->sLabel,
200			 $this->mDefaultValue,
201			 $this->sDesc,
202			 $this->sPlaceholder
203		);
204	}
205}
206