Completed
Push — master ( e96f63...7cd0ea )
by Rob
02:01
created

SoteriaService::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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
}