| Conditions | 6 | 
| Paths | 17 | 
| Total Lines | 26 | 
| Code Lines | 16 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 12 | public static function mergeWhitelists(Whitelist ...$whitelists): Whitelist | ||
| 13 |     { | ||
| 14 | $whitelistGlobalConstants = true; | ||
| 15 | $whitelistGlobalClasses = true; | ||
| 16 | $whitelistGlobalFunctions = true; | ||
| 17 | $elements = []; | ||
| 18 | |||
| 19 |         foreach ($whitelists as $whitelist) { | ||
| 20 | $whitelistGlobalConstants = $whitelistGlobalConstants && $whitelist->whitelistGlobalConstants(); | ||
| 21 | $whitelistGlobalClasses = $whitelistGlobalClasses && $whitelist->whitelistGlobalClasses(); | ||
| 22 | $whitelistGlobalFunctions = $whitelistGlobalFunctions && $whitelist->whitelistGlobalFunctions(); | ||
| 23 | |||
| 24 | $whitelistElements = $whitelist->toArray(); | ||
| 25 | |||
| 26 |             foreach ($whitelistElements as $whitelistElement) { | ||
| 27 | // Do not rely on array_merge here since it can be quite slow. Indeed array_merge copies the two arrays | ||
| 28 | // to merge into a new one, done in a loop like here it can be quite taxing. | ||
| 29 | $elements[] = $whitelistElement; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | return Whitelist::create( | ||
| 34 | $whitelistGlobalConstants, | ||
| 35 | $whitelistGlobalClasses, | ||
| 36 | $whitelistGlobalFunctions, | ||
| 37 | ...$elements | ||
| 38 | ); | ||
| 40 | } |