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

ApieAwareTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApie() 0 6 2
A setApie() 0 6 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
    }
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