Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
18 / 18 |
| Tabs | |
100.00% |
1 / 1 |
|
100.00% |
9 / 9 |
12 | |
100.00% |
18 / 18 |
| getTabs | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| addTab | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
|||
| getTab | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| hasTab | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
| rewind | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| current | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| key | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| next | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| valid | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| <?php | |
| declare(strict_types=1); | |
| namespace Korobochkin\WPKit\Pages\Tabs; | |
| /** | |
| * Class Tabs | |
| */ | |
| class Tabs implements TabsInterface | |
| { | |
| /** | |
| * @var TabInterface[] | |
| */ | |
| protected $tabs = array(); | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function getTabs() | |
| { | |
| return $this->tabs; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function addTab(TabInterface $tab) | |
| { | |
| if (empty($tab->getName())) { | |
| throw new \LogicException(); | |
| } | |
| $this->tabs[$tab->getName()] = $tab; | |
| return $this; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function getTab($name) | |
| { | |
| if ($this->hasTab($name)) { | |
| return $this->tabs[$name]; | |
| } | |
| throw new \InvalidArgumentException(); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function hasTab($name) | |
| { | |
| if (isset($this->tabs[$name])) { | |
| return true; | |
| } | |
| return false; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rewind() | |
| { | |
| reset($this->tabs); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function current() | |
| { | |
| return current($this->tabs); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function key() | |
| { | |
| return key($this->tabs); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function next() | |
| { | |
| next($this->tabs); | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function valid() | |
| { | |
| return isset($this->tabs[$this->key()]); | |
| } | |
| } |