Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
597 B
1
Indexable
Never
<?php

class BurgerWrapper {
    private $burger;
    private $paper;
    
    public function __construct(Burger $burger, Paper $paper)
    {
        $this->burger = $burger;    
        $this->paper = $paper;
    }
    
    public function wrap() 
    {
        return $this->paper->wrapUp($burger);
    }
}

class OrderController 
{
    public function serve(Collection $burgerWrappers)
    {
        $wrappedItems = [];
        
        foreach ($burgerWrappers as $burgerWrapper) {
            $wrappedItems[] = $burgerWrapper->wrap();
        }
        
        return $wrappedItems;
    }
}