1 | <?php |
||
8 | class Collection |
||
9 | { |
||
10 | |||
11 | protected $reflector; |
||
12 | protected $referencial; |
||
13 | protected $headers; |
||
14 | protected $records; |
||
15 | |||
16 | public function __construct(ObjectReflector $reflector) |
||
22 | |||
23 | public function support($entity) |
||
34 | |||
35 | public function getReferencial() |
||
39 | |||
40 | public function setReferencial($entity) |
||
46 | |||
47 | public function attach($entity, array $values = null) |
||
59 | |||
60 | public function search($value) |
||
61 | { |
||
62 | foreach ($this->records as $record) { |
||
63 | $entity = $record->getEntity(); |
||
64 | if (method_exists($entity, '__toString') && (string) $entity === $value) { |
||
65 | return $record; |
||
66 | } |
||
67 | } |
||
68 | |||
69 | foreach ($this->headers as $header) { |
||
70 | foreach ($this->records as $record) { |
||
71 | if (null !== $record->get($header) && $value === $record->get($header)) { |
||
72 | return $record; |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | |||
78 | public function all() |
||
82 | |||
83 | public function count() |
||
87 | |||
88 | protected function mergeHeaders($headers) |
||
96 | |||
97 | protected function buildValues($entity) |
||
115 | } |
||
116 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.