| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait HasParts |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Find all Parts of a message. |
||
| 11 | * Necessary to reset the $allParts Varibale. |
||
| 12 | * |
||
| 13 | * @param collection $partsContainer. F.e. collect([$message->payload]) |
||
| 14 | * |
||
| 15 | * @return Collection of all 'parts' flattened |
||
| 16 | */ |
||
| 17 | private function getAllParts($partsContainer) |
||
| 18 | { |
||
| 19 | global $allParts; |
||
| 20 | $allParts = collect([]); |
||
| 21 | return $this->iterateParts($partsContainer); |
||
| 22 | } |
||
| 23 | |||
| 24 | |||
| 25 | /** |
||
| 26 | * Recursive Method. Iterates through a collection, |
||
| 27 | * finding all 'parts'. |
||
| 28 | * |
||
| 29 | * @param collection $partsContainer. F.e. collect([$message->payload]) |
||
| 30 | * |
||
| 31 | * @return Collection of all 'parts' flattened |
||
| 32 | * @return true if $retunfOnFirstFound is set to true and first part is found. |
||
| 33 | */ |
||
| 34 | |||
| 35 | private function iterateParts( $partsContainer, $returnOnFirstFound = false) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |