Validator.php 814 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Code;
  7. class Validator implements ValidatorInterface
  8. {
  9. /**
  10. * @var ValidatorInterface[]
  11. */
  12. protected $_validators = [];
  13. /**
  14. * Add validator
  15. *
  16. * @param ValidatorInterface $validator
  17. * @return void
  18. */
  19. public function add(ValidatorInterface $validator)
  20. {
  21. $this->_validators[] = $validator;
  22. }
  23. /**
  24. * Validate class
  25. *
  26. * @param string $className
  27. * @return bool
  28. * @throws \Magento\Framework\Exception\ValidatorException
  29. */
  30. public function validate($className)
  31. {
  32. foreach ($this->_validators as $validator) {
  33. $validator->validate($className);
  34. }
  35. }
  36. }