AttributeSubjectInterface.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * This file is part of the Sylius package.
  4. *
  5. * (c); Paweł Jędrzejewski
  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 Sylius\Component\Attribute\Model;
  11. use Doctrine\Common\Collections\Collection;
  12. /**
  13. * Interface implemented by object which can be characterized
  14. * using the attributes.
  15. *
  16. * @author Paweł Jędrzejewski <pawel@sylius.org>
  17. */
  18. interface AttributeSubjectInterface
  19. {
  20. /**
  21. * Returns all attributes of the subject.
  22. *
  23. * @return Collection|AttributeValueInterface[]
  24. */
  25. public function getAttributes();
  26. /**
  27. * Sets all attributes of the subject.
  28. *
  29. * @param Collection $attributes Array of AttributeValueInterface
  30. */
  31. public function setAttributes(Collection $attributes);
  32. /**
  33. * Adds an attribute to the subject.
  34. *
  35. * @param AttributeValueInterface $attribute
  36. */
  37. public function addAttribute(AttributeValueInterface $attribute);
  38. /**
  39. * Removes an attribute from the subject.
  40. *
  41. * @param AttributeValueInterface $attribute
  42. */
  43. public function removeAttribute(AttributeValueInterface $attribute);
  44. /**
  45. * Checks whether the subject has a given attribute.
  46. *
  47. * @param AttributeValueInterface $attribute
  48. *
  49. * @return Boolean
  50. */
  51. public function hasAttribute(AttributeValueInterface $attribute);
  52. /**
  53. * Checks whether the subject has a given attribute, access by name.
  54. *
  55. * @param string $attributeName
  56. *
  57. * @return Boolean
  58. */
  59. public function hasAttributeByName($attributeName);
  60. /**
  61. * Returns an attribute of the subject by its name.
  62. *
  63. * @param string $attributeName
  64. *
  65. * @return AttributeValueInterface
  66. */
  67. public function getAttributeByName($attributeName);
  68. }