| Total Complexity | 17 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Coverage | 56% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class OfferPackage extends Simple |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var Offer[] |
||
| 17 | */ |
||
| 18 | protected $offers = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var Simple[] array |
||
| 22 | */ |
||
| 23 | protected $priceTypes = []; |
||
| 24 | |||
| 25 | 8 | public function loadXml() |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return Offer[] |
||
| 36 | */ |
||
| 37 | 1 | public function getOffers() |
|
| 38 | { |
||
| 39 | 1 | if (!$this->offers && $this->xml && $this->xml->Предложения) { |
|
|
|
|||
| 40 | 1 | foreach ($this->xml->Предложения->Предложение as $offer) { |
|
| 41 | 1 | $this->offers[] = new Offer($this->owner, $offer); |
|
| 42 | } |
||
| 43 | } |
||
| 44 | 1 | return $this->offers; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return Simple[] |
||
| 49 | */ |
||
| 50 | public function getPriceTypes() |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param $id |
||
| 62 | * @return null|Offer |
||
| 63 | * @deprecated will removed in 0.3.0 |
||
| 64 | */ |
||
| 65 | public function getOfferById($id) |
||
| 66 | { |
||
| 67 | foreach ($this->getOffers() as $offer) { |
||
| 68 | if ($offer->getClearId() == $id) { |
||
| 69 | return $offer; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | return null; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param $id |
||
| 77 | * @return Offer[] |
||
| 78 | */ |
||
| 79 | 1 | public function getOffersById($id) |
|
| 88 | } |
||
| 89 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.