| 1 | <?php |
||
| 19 | class MiddlewareQueue implements IteratorAggregate |
||
| 20 | { |
||
| 21 | public const DEFAULT_PRIORITY = 100; |
||
| 22 | |||
| 23 | /** @var int counter for FIFO order for items with same priority */ |
||
| 24 | protected $serial = PHP_INT_MAX; |
||
| 25 | |||
| 26 | /** @var SplPriorityQueue middleware */ |
||
| 27 | protected $queue; |
||
| 28 | |||
| 29 | 5 | public function __construct() |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Adds middleware to queue |
||
| 36 | * |
||
| 37 | * @param MiddlewareInterface $middleware |
||
| 38 | * @param int $priority |
||
| 39 | * @return \self |
||
| 40 | */ |
||
| 41 | 5 | public function add(MiddlewareInterface $middleware, int $priority = self::DEFAULT_PRIORITY): self |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Implements IteratorAggregate |
||
| 49 | * |
||
| 50 | * @return Traversable |
||
| 51 | */ |
||
| 52 | 5 | public function getIterator(): Traversable |
|
| 56 | } |
||
| 57 |