Completed
Pull Request — master (#2)
by Pedro
01:50
created

Factory::getProxy()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.864

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 2
cts 5
cp 0.4
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2.864
1
<?php
2
3
namespace Pcelta\Doctrine\Cache;
4
5
use Pcelta\Doctrine\Cache\Entity\Config;
6
use Doctrine\Common\Cache\CacheProvider;
7
use Pcelta\Doctrine\Cache\Exception\InvalidCacheConfig;
8
use Pcelta\Doctrine\Cache\Factory;
9
10
class Factory
11
{
12
    /**
13
     * @param Proxy $proxy
14
     */
15
    public function setProxy(Proxy $proxy)
16
    {
17
        $this->proxy = $proxy;
0 ignored issues
show
Bug introduced by
The property proxy does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
    }
19 1
20
    /**
21
     * @param array $cacheSettings
22
     * @return CacheProvider
23
     * @throws InvalidCacheConfig
24
     */
25 1
    public function create(array $cacheSettings)
26
    {
27
        $config = new Config($cacheSettings);
28
29
        $class = sprintf('\Pcelta\Doctrine\Cache\Factory\%sFactory', $config->getAdapterName());
30
31 1
        if (!class_exists($class)) {
32
            throw new InvalidCacheConfig('Adapter not found');
33 1
        }
34 1
35
        /** @var Factory\AbstractFactory $factory */
36
        $this->factory = new $class();
0 ignored issues
show
Bug introduced by
The property factory does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
        return $this->factory->create($config);
38
    }
39
}
40