Passed
Branch 3.0.0 (3c68a7)
by Pieter
04:04
created

ApieAwareTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApie() 0 6 2
A setApie() 0 7 2
1
<?php
2
3
4
namespace W2w\Lib\Apie\PluginInterfaces;
5
6
use W2w\Lib\Apie\Apie;
7
use W2w\Lib\Apie\Exceptions\BadConfigurationException;
8
9
trait ApieAwareTrait
10
{
11
    private $apie;
12
13
    public function setApie(Apie $apie)
14
    {
15
        if ($this->apie) {
16
            throw new BadConfigurationException('setApie should only be called once');
17
        }
18
        $this->apie = $apie;
19
        return $this;
20
    }
21
22
    protected function getApie(): Apie
23
    {
24
        if (!$this->apie) {
25
            throw new BadConfigurationException('setApie is not being called');
26
        }
27
        return $this->apie;
28
    }
29
}
30