Total Complexity | 8 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
8 | trait HasParts |
||
9 | { |
||
10 | /** |
||
11 | * LOL |
||
12 | * @var Collection |
||
13 | */ |
||
14 | private $allParts; |
||
15 | |||
16 | /** |
||
17 | * Find all Parts of a message. |
||
18 | * Necessary to reset the $allParts Varibale. |
||
19 | * |
||
20 | * @param collection $partsContainer . F.e. collect([$message->payload]) |
||
21 | * |
||
22 | * @return Collection of all 'parts' flattened |
||
23 | */ |
||
24 | private function getAllParts($partsContainer) |
||
25 | { |
||
26 | $this->iterateParts($partsContainer); |
||
27 | |||
28 | return collect($this->allParts); |
||
29 | } |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Recursive Method. Iterates through a collection, |
||
34 | * finding all 'parts'. |
||
35 | * |
||
36 | * @param collection $partsContainer |
||
37 | * @param bool $returnOnFirstFound |
||
38 | * |
||
39 | * @return Collection|boolean |
||
40 | */ |
||
41 | |||
42 | private function iterateParts($partsContainer, $returnOnFirstFound = false) |
||
66 | } |
||
67 | } |
||
71 |