MetadataBag.php 900 B

123456789101112131415161718192021222324252627282930313233343536373839
  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\Metadata;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. /**
  13. * Container for Metadatas
  14. *
  15. * @author Romain Neutron - imprec@gmail.com
  16. * @license http://opensource.org/licenses/MIT MIT
  17. */
  18. class MetadataBag extends ArrayCollection
  19. {
  20. /**
  21. * Returns all the elements which key matches the regexp
  22. *
  23. * @param string $regexp
  24. * @return MetadataBag
  25. */
  26. public function filterKeysByRegExp($regexp)
  27. {
  28. $partitions = $this->partition(function($key, $element) use ($regexp) {
  29. return preg_match($regexp, $key);
  30. });
  31. return array_shift($partitions);
  32. }
  33. }