| Total Complexity | 7 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 69.23% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class ShippingMethodCollection extends Collection |
||
| 19 | { |
||
| 20 | const NAME = 'name'; |
||
| 21 | |||
| 22 | protected $type = ShippingMethod::class; |
||
| 23 | |||
| 24 | 5 | protected function indexRow($offset, $row) |
|
| 25 | { |
||
| 26 | 5 | if ($row instanceof ShippingMethod) { |
|
| 27 | $name = $row->getName(); |
||
| 28 | $id = $row->getId(); |
||
| 29 | } else { |
||
| 30 | 5 | $name = isset($row[static::NAME]) ? $row[static::NAME] : null; |
|
| 31 | 5 | $id = isset($row[static::ID]) ? $row[static::ID] : null; |
|
| 32 | } |
||
| 33 | 5 | if (!empty($name)) { |
|
| 34 | 2 | $this->addToIndex(static::NAME, $offset, $name); |
|
| 35 | } |
||
| 36 | 5 | if (!empty($id)) { |
|
| 37 | 2 | $this->addToIndex(static::ID, $offset, $id); |
|
| 38 | } |
||
| 39 | 5 | } |
|
| 40 | |||
| 41 | /** |
||
| 42 | * @param $name |
||
| 43 | * @return ShippingMethod |
||
| 44 | */ |
||
| 45 | public function getByName($name) |
||
| 48 | } |
||
| 49 | } |
||
| 50 |