Completed
Push — develop ( 9659b8...659b85 )
by Mathias
13:02
created

BaseEvent::setParams()   A

Complexity

Conditions 6
Paths 5

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.1111
c 0
b 0
f 0
cc 6
nc 5
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2018 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Service\EntityEraser;
12
use Zend\EventManager\Event;
13
14
/**
15
 * Base event for EntityEraser.
16
 * 
17
 * @author Mathias Gelhausen <[email protected]>
18
 * @todo write test 
19
 */
20
class BaseEvent extends Event
21
{
22
    /**
23
     * @var \Core\Repository\RepositoryService
24
     */
25
    private $repositories;
26
27
    /**
28
     * @return \Core\Repository\RepositoryService
29
     */
30
    public function getRepositories()
31
    {
32
        return $this->repositories;
33
    }
34
35
    /**
36
     * @param \Core\Repository\RepositoryService $repositories
37
     *
38
     * @return self
39
     */
40
    public function setRepositories($repositories)
41
    {
42
        $this->repositories = $repositories;
43
44
        return $this;
45
    }
46
47
    /**
48
     * Get a entity repository from the repository service
49
     *
50
     * @param string $name
51
     *
52
     * @return \Doctrine\Common\Persistence\ObjectRepository|\Doctrine\ODM\MongoDB\DocumentRepository|\Core\Repository\RepositoryInterface
53
     */
54
    public function getRepository($name)
55
    {
56
        return $this->getRepositories()->get($name);
57
    }
58
59
    public function setParam($name, $value)
60
    {
61
62
        if ('repositories' == $name) {
63
            $this->setRepositories($value);
64
            return;
65
        }
66
67
        parent::setParam($name, $value);
68
    }
69
70 View Code Duplication
    public function setParams($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        if (is_array($params) || $params instanceOf \ArrayAccess) {
73
            if (isset($params['repositories'])) {
74
                $this->setRepositories($params['repositories']);
75
                unset($params['repositories']);
76
            }
77
        } else if (is_object($params)) {
78
            if (isset($params->repositories)) {
79
                $this->setRepositories($params->repositories);
80
                unset($params->repositories);
81
            }
82
        }
83
84
        parent::setParams($params);
85
    }
86
87
}
88