Passed
Branch 3.0.0 (0ebb76)
by Pieter
02:27
created

ApieAwareTrait::setApie()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
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
    }
20
21
    protected function getApie(): Apie
22
    {
23
        if (!$this->apie) {
24
            throw new BadConfigurationException('setApie is not being called');
25
        }
26
        return $this->apie;
27
    }
28
}
29