DoctrineStrictObjectManager   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A findOrFail() 0 10 2
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
}