ArrayIntersector.php
19 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Pelago\Emogrifier\Utilities; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | class ArrayIntersector |
| 6 | { |
| 7 | private $invertedArray; |
| 8 | public function __construct(array $array) |
| 9 | { |
| 10 | $this->invertedArray = \array_flip($array); |
| 11 | } |
| 12 | public function intersectWith(array $array) : array |
| 13 | { |
| 14 | $invertedArray = \array_flip($array); |
| 15 | $invertedIntersection = \array_intersect_key($invertedArray, $this->invertedArray); |
| 16 | return \array_flip($invertedIntersection); |
| 17 | } |
| 18 | } |
| 19 |