Multi.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * This file is part of the PHPExiftool package.
  4. *
  5. * (c) Alchemy <support@alchemy.fr>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PHPExiftool\Driver\Value;
  11. class Multi implements ValueInterface
  12. {
  13. protected $value = array();
  14. public function __construct($value = null)
  15. {
  16. if ($value) {
  17. $this->addValue($value);
  18. }
  19. }
  20. public function getType()
  21. {
  22. return self::TYPE_MULTI;
  23. }
  24. public function addValue($value)
  25. {
  26. $this->value = array_merge($this->value, (array) $value);
  27. return $this;
  28. }
  29. public function set($value)
  30. {
  31. $this->value = (array) $value;
  32. return $this;
  33. }
  34. public function reset()
  35. {
  36. $this->value = array();
  37. return $this;
  38. }
  39. public function serialize($separator = ' ; ')
  40. {
  41. return implode($separator, $this->value);
  42. }
  43. public function asString()
  44. {
  45. return $this->serialize();
  46. }
  47. public function asArray()
  48. {
  49. return $this->value;
  50. }
  51. public function __toString()
  52. {
  53. return $this->serialize();
  54. }
  55. }