| @@ 7-40 (lines=34) @@ | ||
| 4 | ||
| 5 | use Kwk\Geckoboard\Dataset\TypeInterface; |
|
| 6 | ||
| 7 | class NumberType implements TypeInterface |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var string |
|
| 11 | */ |
|
| 12 | private $name; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var bool |
|
| 16 | */ |
|
| 17 | private $isOptional; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @param string $name |
|
| 21 | * @param bool $isOptional |
|
| 22 | */ |
|
| 23 | public function __construct($name, $isOptional = false) |
|
| 24 | { |
|
| 25 | $this->name = $name; |
|
| 26 | $this->isOptional = $isOptional; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * {@inheritDoc} |
|
| 31 | */ |
|
| 32 | public function toArray() |
|
| 33 | { |
|
| 34 | return [ |
|
| 35 | 'type' => 'number', |
|
| 36 | 'name' => $this->name, |
|
| 37 | 'optional' => $this->isOptional, |
|
| 38 | ]; |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 7-40 (lines=34) @@ | ||
| 4 | ||
| 5 | use Kwk\Geckoboard\Dataset\TypeInterface; |
|
| 6 | ||
| 7 | class PercentageType implements TypeInterface |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var string |
|
| 11 | */ |
|
| 12 | private $name; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @var bool |
|
| 16 | */ |
|
| 17 | private $isOptional; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @param string $name |
|
| 21 | * @param bool $isOptional |
|
| 22 | */ |
|
| 23 | public function __construct($name, $isOptional = false) |
|
| 24 | { |
|
| 25 | $this->name = $name; |
|
| 26 | $this->isOptional = $isOptional; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * {@inheritDoc} |
|
| 31 | */ |
|
| 32 | public function toArray() |
|
| 33 | { |
|
| 34 | return [ |
|
| 35 | 'type' => 'percentage', |
|
| 36 | 'name' => $this->name, |
|
| 37 | 'optional' => $this->isOptional, |
|
| 38 | ]; |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||