| @@ 27-91 (lines=65) @@ | ||
| 24 | * @category PHPExif |
|
| 25 | * @package Common |
|
| 26 | */ |
|
| 27 | abstract class FloatObject implements JsonSerializable |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * Contains the value |
|
| 31 | * |
|
| 32 | * @var float |
|
| 33 | */ |
|
| 34 | protected $value; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param int $value |
|
| 38 | * |
|
| 39 | * @throws InvalidArgumentException If given data is not an float |
|
| 40 | */ |
|
| 41 | public function __construct($value) |
|
| 42 | { |
|
| 43 | if (!is_float($value)) { |
|
| 44 | throw new InvalidArgumentException('Given data is not a float'); |
|
| 45 | } |
|
| 46 | ||
| 47 | $this->setValue($value); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Sets the value |
|
| 52 | * |
|
| 53 | * @param float $value |
|
| 54 | * |
|
| 55 | * @return void |
|
| 56 | */ |
|
| 57 | protected function setValue($value) |
|
| 58 | { |
|
| 59 | $this->value = $value; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Getter for value |
|
| 64 | * |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getValue() |
|
| 68 | { |
|
| 69 | return $this->value; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @inheritDoc |
|
| 74 | * |
|
| 75 | * @return string |
|
| 76 | */ |
|
| 77 | public function jsonSerialize() |
|
| 78 | { |
|
| 79 | return (float) $this->getValue(); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Returns string representation |
|
| 84 | * |
|
| 85 | * @return string |
|
| 86 | */ |
|
| 87 | public function __toString() |
|
| 88 | { |
|
| 89 | return (string) $this->getValue(); |
|
| 90 | } |
|
| 91 | } |
|
| 92 | ||
| @@ 27-91 (lines=65) @@ | ||
| 24 | * @category PHPExif |
|
| 25 | * @package Common |
|
| 26 | */ |
|
| 27 | abstract class IntegerObject implements JsonSerializable |
|
| 28 | { |
|
| 29 | /** |
|
| 30 | * Contains the value |
|
| 31 | * |
|
| 32 | * @var int |
|
| 33 | */ |
|
| 34 | protected $value; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @param int $value |
|
| 38 | * |
|
| 39 | * @throws InvalidArgumentException If given data is not an integer |
|
| 40 | */ |
|
| 41 | public function __construct($value) |
|
| 42 | { |
|
| 43 | if (!is_int($value)) { |
|
| 44 | throw new InvalidArgumentException('Given data is not an integer'); |
|
| 45 | } |
|
| 46 | ||
| 47 | $this->setValue($value); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Sets the value |
|
| 52 | * |
|
| 53 | * @param int $value |
|
| 54 | * |
|
| 55 | * @return void |
|
| 56 | */ |
|
| 57 | protected function setValue($value) |
|
| 58 | { |
|
| 59 | $this->value = $value; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Getter for value |
|
| 64 | * |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getValue() |
|
| 68 | { |
|
| 69 | return $this->value; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @inheritDoc |
|
| 74 | * |
|
| 75 | * @return string |
|
| 76 | */ |
|
| 77 | public function jsonSerialize() |
|
| 78 | { |
|
| 79 | return (int) $this->getValue(); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Returns string representation |
|
| 84 | * |
|
| 85 | * @return string |
|
| 86 | */ |
|
| 87 | public function __toString() |
|
| 88 | { |
|
| 89 | return (string) $this->getValue(); |
|
| 90 | } |
|
| 91 | } |
|
| 92 | ||