RestResourcePatch::beforePatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Rest/Traits/RestResourcePatch.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Rest\Traits;
10
11
use App\DTO\RestDtoInterface;
12
use App\Entity\Interfaces\EntityInterface;
13
14
/**
15
 * Trait RestResourcePatch
16
 *
17
 * @SuppressWarnings("unused")
18
 *
19
 * @package App\Rest\Traits
20
 * @author TLe, Tarmo Leppänen <[email protected]>
21
 */
22
trait RestResourcePatch
23
{
24
    /**
25
     * Before lifecycle method for patch method.
26
     */
27 12
    public function beforePatch(string &$id, RestDtoInterface $restDto, EntityInterface $entity): void
28
    {
29 12
    }
30
31
    /**
32
     * After lifecycle method for patch method.
33
     *
34
     * Notes: If you make changes to entity in this lifecycle method by default it will be saved on end of current
35
     *          request. To prevent this you need to detach current entity from entity manager.
36
     *
37
     *          Also note that if you've made some changes to entity and you eg. throw an exception within this method
38
     *          your entity will be saved if it has eg Blameable / Timestampable traits attached.
39
     */
40 12
    public function afterPatch(string &$id, RestDtoInterface $dto, EntityInterface $entity): void
41
    {
42 12
    }
43
}
44