Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
EntityAlreadyPersisted
90.00% covered (success)
90.00%
9 / 10
50.00% covered (danger)
50.00%
1 / 2
2.00
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 getStatusCode
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace Apie\Core\Exceptions;
3
4use Apie\Core\Entities\EntityInterface;
5use ReflectionClass;
6use Throwable;
7
8final class EntityAlreadyPersisted extends ApieException implements HttpStatusCodeException
9{
10    public function __construct(EntityInterface $entity, ?Throwable $previous = null)
11    {
12        parent::__construct(
13            sprintf(
14                "Entity '%s' with id '%s' is already persisted in the persistence layer!",
15                (new ReflectionClass($entity))->getShortName(),
16                $entity->getId()->toNative()
17            ),
18            0,
19            $previous
20        );
21    }
22
23    public function getStatusCode(): int
24    {
25        return 409;
26    }
27}