Completed
Push — master ( c6aea9...538fb8 )
by Flo
05:04 queued 02:10
created

ORM::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * Class ORM | ORM.php
4
 * @package Faulancer\Service
5
 * @author  Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\Service;
8
9
use ORM\EntityFetcher;
10
use ORM\EntityManager;
11
use Faulancer\ORM\Entity;
12
use Faulancer\ServiceLocator\ServiceInterface;
13
14
/**
15
 * Class ORM
16
 */
17
class ORM implements ServiceInterface
18
{
19
20
    /** @var EntityManager */
21
    protected $entityManager;
22
23
    /**
24
     * ORM constructor.
25
     * @param EntityManager $entityManager
26
     */
27
    public function __construct(EntityManager $entityManager)
28
    {
29
        $this->entityManager = $entityManager;
30
    }
31
32
    /**
33
     * @param string       $entity
34
     * @param integer|null $primaryKey
35
     * @return EntityFetcher
36
     * @codeCoverageIgnore
37
     */
38
    public function fetch(string $entity, $primaryKey = null)
39
    {
40
        return $this->entityManager->fetch($entity, $primaryKey);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->entityManager->fe...($entity, $primaryKey); of type ORM\EntityFetcher|ORM\Entity adds the type ORM\Entity to the return on line 40 which is incompatible with the return type documented by Faulancer\Service\ORM::fetch of type ORM\EntityFetcher.
Loading history...
41
    }
42
43
    /**
44
     * @param Entity $entity
45
     * @codeCoverageIgnore
46
     */
47
    public function save(Entity $entity)
48
    {
49
        $entity->save($this->entityManager);
50
    }
51
52
}