Completed
Push — master ( 7bccf6...d15e2a )
by Rob
01:53
created

SoteriaService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 27
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 4 1
A buildSecurity() 0 8 2
A getFactory() 0 7 2
1
<?php
2
3
namespace devtoolboxuk\soteria;
4
5
use devtoolboxuk\soteria\handlers\XssClean;
6
7
8
class SoteriaService //implements SoteriaInterface
9
{
10
11
    protected $factory;
12
13 6
    public function __call($method, $arguments)
14
    {
15 6
        return $this->buildSecurity($method);
16
    }
17
18 6
    public function buildSecurity($ruleSpec)
19
    {
20
        try {
21 6
            return $this->getFactory()->build($ruleSpec);
22
        } catch (\Exception $exception) {
23
            throw new \Exception($exception);
24
        }
25
    }
26
27 6
    protected function getFactory()
28
    {
29 6
        if (!$this->factory instanceof SoteriaFactory) {
30 6
            $this->factory = new SoteriaFactory();
31 6
        }
32 6
        return $this->factory;
33
    }
34
}