DoctrineStrictObjectManager::findOrFail()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Infrastructure;
4
5
use App\Exceptions\ServiceException;
6
use Doctrine\ORM\Decorator\EntityManagerDecorator;
7
8
final class DoctrineStrictObjectManager extends EntityManagerDecorator implements StrictObjectManager
9
{
10
    /**
11
     * @param string $entityName
12
     * @param $id
13
     * @return null|object
14
     */
15
    public function findOrFail(string $entityName, $id)
16
    {
17
        $entity = $this->wrapped->find($entityName, $id);
18
19
        if ($entity === null)
20
        {
21
            throw new ServiceException(basename(str_replace('\\', '/', $entityName)) . ' not found');
22
        }
23
24
        return $entity;
25
    }
26
}