Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. namespace MyBundle\Validator;
  4.  
  5. /**
  6. * Class InraConstraintClassRegistry
  7. * @package Inra\ScemBundle\Validator
  8. *
  9. * Based on EzSystems\EzPlatformFormBuilder\Definition\Validator\ConstraintClassRegistry
  10. */
  11. class MyConstraintClassRegistry /* extends ConstraintClassRegistry */
  12. {
  13. /**
  14. * @var array
  15. */
  16. protected $registry = [];
  17.  
  18. /**
  19. * @param string $identifier
  20. *
  21. * @return bool
  22. */
  23. public function hasConstraintClass(string $identifier)
  24. {
  25. return isset($this->registry[$identifier]);
  26. }
  27.  
  28. /**
  29. * @param string $identifier
  30. *
  31. * @return string|null
  32. */
  33. public function getConstraintClass(string $identifier): ?string
  34. {
  35. return $this->hasConstraintClass($identifier)
  36. ? $this->registry[$identifier]
  37. : null;
  38. }
  39.  
  40. /**
  41. * @return array
  42. */
  43. public function getConstraintClasses(): array
  44. {
  45. return $this->registry;
  46. }
  47.  
  48. /**
  49. * @param string $identifier
  50. * @param string $constraintClass
  51. */
  52. public function setConstraintClass(string $identifier, string $constraintClass): void
  53. {
  54. $this->registry[$identifier] = $constraintClass;
  55. }
  56.  
  57. /**
  58. * @param array $constraintClasses
  59. */
  60. public function setConstraintClasses(array $constraintClasses)
  61. {
  62. $this->registry = $constraintClasses;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement