| Total Complexity | 7 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace FlatPlan\Components; |
||
| 3 | class Ad extends AbstractComponent { |
||
| 4 | |||
| 5 | protected $bannerType; |
||
| 6 | |||
| 7 | protected $roles = ['banner_advertisement', 'medium_rectangle_advertisement']; |
||
| 8 | protected $bannerTypes = ['any', 'standard', 'double_height', 'large']; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @param string $role |
||
| 12 | * @param string $bannerType |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public function __construct($role, $bannerType = null) |
||
| 16 | { |
||
| 17 | $this->setRole($role); |
||
| 18 | if ($role === 'banner_advertisement') { |
||
| 19 | $this->setBannerType($bannerType); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | private function setBannerType($bannerType = null) |
||
| 24 | { |
||
| 25 | if (!in_array($bannerType, $this->bannerTypes)) { |
||
| 26 | throw new \ErrorException('Invalid banner type supplied.'); |
||
| 27 | } |
||
| 28 | $this->bannerTypes = $bannerType; |
||
| 29 | } |
||
| 30 | |||
| 31 | private function getBannerType() |
||
| 32 | { |
||
| 33 | return $this->bannerType; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getComponent() |
||
| 47 | } |
||
| 48 | } |
||
| 49 |