1 | <?php |
||
28 | trait TagAwareTrait |
||
29 | { |
||
30 | /** |
||
31 | * associate array (for speed consideration) of tags |
||
32 | * |
||
33 | * @var array |
||
34 | * @access private |
||
35 | */ |
||
36 | private $tags = []; |
||
37 | |||
38 | /** |
||
39 | * Add a single tag |
||
40 | * |
||
41 | * @param string $tag |
||
42 | * @return $this |
||
43 | * @access public |
||
44 | * @api |
||
45 | */ |
||
46 | public function addTag(/*# string */ $tag) |
||
51 | |||
52 | /** |
||
53 | * Has this tag ? |
||
54 | * |
||
55 | * @param string $tag |
||
56 | * @return bool |
||
57 | * @access public |
||
58 | * @api |
||
59 | */ |
||
60 | public function hasTag(/*# string */ $tag)/*# : bool */ |
||
64 | |||
65 | /** |
||
66 | * Remove one tag |
||
67 | * |
||
68 | * @param string $tag |
||
69 | * @return $this |
||
70 | * @access public |
||
71 | * @api |
||
72 | */ |
||
73 | public function removeTag(/*# string */ $tag) |
||
78 | |||
79 | /** |
||
80 | * Set/replace all tags, empty array to clear all tags |
||
81 | * |
||
82 | * @param array $tags like ['apple', 'orange'] |
||
83 | * @return $this |
||
84 | * @access public |
||
85 | * @api |
||
86 | */ |
||
87 | public function setTags(array $tags) |
||
92 | |||
93 | /** |
||
94 | * Get all tags in array |
||
95 | * |
||
96 | * @return array |
||
97 | * @access public |
||
98 | * @api |
||
99 | */ |
||
100 | public function getTags()/*# : array */ |
||
104 | |||
105 | /** |
||
106 | * Return array of tags existed, return empty [] if no match found |
||
107 | * |
||
108 | * @param array $tags tags to match against |
||
109 | * @return array |
||
110 | * @access public |
||
111 | * @api |
||
112 | */ |
||
113 | public function hasTags(array $tags)/*# : array */ |
||
123 | } |
||
124 |