snappymail/rainloop/v/0.0.0/app/libraries/RainLoop/Plugins/Property.php

154 lines
2.1 KiB
PHP
Raw Normal View History

2014-10-18 20:52:51 +08:00
<?php
namespace RainLoop\Plugins;
class Property
{
/**
* @var string
*/
private $sName;
2014-10-18 20:52:51 +08:00
/**
* @var string
*/
private $sLabel;
/**
* @var string
*/
private $sDesc;
2014-10-18 20:52:51 +08:00
/**
* @var int
*/
private $iType;
/**
* @var bool
*/
private $bAllowedInJs;
2014-10-18 20:52:51 +08:00
/**
* @var mixed
*/
private $mDefaultValue;
/**
* @var string
*/
private $sPlaceholder;
private function __construct(string $sName)
2014-10-18 20:52:51 +08:00
{
$this->sName = $sName;
$this->iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
$this->mDefaultValue = '';
$this->sLabel = '';
$this->sDesc = '';
$this->bAllowedInJs = false;
$this->sPlaceholder = '';
}
public static function NewInstance(string $sName) : self
2014-10-18 20:52:51 +08:00
{
return new self($sName);
}
public function SetType(int $iType) : self
2014-10-18 20:52:51 +08:00
{
$this->iType = (int) $iType;
2014-10-18 20:52:51 +08:00
return $this;
}
2014-10-18 20:52:51 +08:00
/**
* @param mixed $mDefaultValue
*/
public function SetDefaultValue($mDefaultValue) : self
2014-10-18 20:52:51 +08:00
{
$this->mDefaultValue = $mDefaultValue;
2014-10-18 20:52:51 +08:00
return $this;
}
public function SetPlaceholder(string $sPlaceholder) : self
2014-10-18 20:52:51 +08:00
{
$this->sPlaceholder = $sPlaceholder;
return $this;
}
public function SetLabel(string $sLabel) : self
2014-10-18 20:52:51 +08:00
{
$this->sLabel = $sLabel;
2014-10-18 20:52:51 +08:00
return $this;
}
public function SetDescription(string $sDesc) : self
2014-10-18 20:52:51 +08:00
{
$this->sDesc = $sDesc;
return $this;
}
public function SetAllowedInJs(bool $bValue = true) : self
2014-10-18 20:52:51 +08:00
{
$this->bAllowedInJs = !!$bValue;
return $this;
}
public function Name() : string
2014-10-18 20:52:51 +08:00
{
return $this->sName;
}
public function AllowedInJs() : bool
2014-10-18 20:52:51 +08:00
{
return $this->bAllowedInJs;
}
public function Description() : string
2014-10-18 20:52:51 +08:00
{
return $this->sDesc;
}
public function Label() : string
2014-10-18 20:52:51 +08:00
{
return $this->sLabel;
}
public function Type() : int
2014-10-18 20:52:51 +08:00
{
return $this->iType;
}
2014-10-18 20:52:51 +08:00
/**
* @return mixed
*/
public function DefaultValue()
{
return $this->mDefaultValue;
}
public function Placeholder() : string
2014-10-18 20:52:51 +08:00
{
return $this->sPlaceholder;
}
public function ToArray() : array
2014-10-18 20:52:51 +08:00
{
return array(
'',
$this->sName,
$this->iType,
$this->sLabel,
$this->mDefaultValue,
$this->sDesc,
$this->sPlaceholder
);
}
}