public function find($data)
    {
        $matches = [];

        foreach ($this->getItems() as $item) {
            if ($item->find($data)) {
                $matches[] = $item;
            }
        }

        switch (count($matches)) {
            case 0:
                return;
                break;
            case 1:
                return $matches[0];
                break;
            default:
                return $matches;
        }
    }
public function find($data)
    {
        $matches = [];

        foreach ($this->getItems() as $item) {
            if ($item->find($data)) {
                $matches[] = $item;
            }
        }

        switch (count($matches)) {
            case 0:
                return;
                break;
            case 1:
                return $matches[0];
                break;
            default:
                return $matches;
        }
    }
public function find ( $ data ) { $ matches = [ ] ; foreach ( $ this -> getItems ( ) as $ item ) { if ( $ item -> find ( $ data ) ) { $ matches [ ] = $ item ; } } switch ( count ( $ matches ) ) { case 0 : return ; break ; case 1 : return $ matches [ 0 ] ; break ; default : return $ matches ; } }
Find items in the cart matching a data set.

param $data

@return array | CartItem | null
Find items in the cart matching a data set .