| 1 | <?php  | 
            ||
| 14 | class TestConstrainedTestItem extends TestItem implements ConstrainedItem  | 
            ||
| 15 | { | 
            ||
| 16 | /**  | 
            ||
| 17 | * @var int  | 
            ||
| 18 | */  | 
            ||
| 19 | public static $limit = 3;  | 
            ||
| 20 | |||
| 21 | /**  | 
            ||
| 22 | * @param ItemList $alreadyPackedItems  | 
            ||
| 23 | * @param TestBox $box  | 
            ||
| 24 | *  | 
            ||
| 25 | * @return bool  | 
            ||
| 26 | */  | 
            ||
| 27 | public function canBePackedInBox(ItemList $alreadyPackedItems, Box $box)  | 
            ||
| 28 |     { | 
            ||
| 29 | $alreadyPackedType = array_filter(  | 
            ||
| 30 | $alreadyPackedItems->asArray(),  | 
            ||
| 31 |             function (TestItem $item) { | 
            ||
| 32 | return $item->getDescription() === $this->getDescription();  | 
            ||
| 33 | }  | 
            ||
| 34 | );  | 
            ||
| 35 | |||
| 36 | return count($alreadyPackedType) + 1 <= static::$limit;  | 
            ||
| 37 | }  | 
            ||
| 38 | }  | 
            ||
| 39 |