ReservationService::deleteReservation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 4
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Service\Parking;
12
13
use App\Entity\Parking\Member;
14
use App\Entity\Parking\Reservation;
15
use App\Enum\Entity\ReservationTypeEnum;
16
use App\Enum\Functional\PermissionEnum;
17
use App\Repository\Entity\Parking\ReservationRepository;
18
use App\Traits\AssertTrait;
19
use Symfony\Component\Security\Core\Security;
20
use Symfony\Component\Validator\Validator\ValidatorInterface;
21
22
class ReservationService
23
{
24
    use AssertTrait;
25
26
    /** @var ReservationRepository */
27
    private $reservationRepository;
28
    /** @var ValidatorInterface */
29
    private $validator;
30
    /** @var Security */
31
    private $security;
32
33 1
    public function __construct(ReservationRepository $reservationRepository, ValidatorInterface $validator, Security $security)
34
    {
35 1
        $this->reservationRepository = $reservationRepository;
36 1
        $this->validator = $validator;
37 1
        $this->security = $security;
38 1
    }
39
40
    public function updateReservation(
41
        Reservation $reservation,
42
        int $places,
43
        ReservationTypeEnum $reservationTypeEnum
44
    ): Reservation {
45
        $reservation->setPlaces($places);
46
        $reservation->setType($reservationTypeEnum);
47
        $this->assertIsValidObject($this->validator, $reservation);
0 ignored issues
show
Documentation introduced by
$reservation is of type object<App\Entity\Parking\Reservation>, but the function expects a object<App\Traits\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
        $this->assertIsGranted($this->security, PermissionEnum::PARKING_RESERVATION_UPDATE, $reservation);
0 ignored issues
show
Documentation introduced by
$reservation is of type object<App\Entity\Parking\Reservation>, but the function expects a null|object<App\Traits\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
50
        $this->reservationRepository->saveAll($reservation);
51
52
        return $reservation;
53
    }
54
55 1
    public function createReservation(
56
        Member $member,
57
        \DateTimeImmutable $date,
58
        int $places,
59
        ReservationTypeEnum $reservationTypeEnum
60
    ): Reservation {
61 1
        $reservation = new Reservation(
62 1
            $member,
63
            $date,
64
            $places,
65
            $reservationTypeEnum
66
        );
67 1
        $this->assertIsValidObject($this->validator, $reservation);
0 ignored issues
show
Documentation introduced by
$reservation is of type object<App\Entity\Parking\Reservation>, but the function expects a object<App\Traits\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68 1
        $this->assertIsGranted($this->security, PermissionEnum::PARKING_RESERVATION_CREATE, $reservation);
0 ignored issues
show
Documentation introduced by
$reservation is of type object<App\Entity\Parking\Reservation>, but the function expects a null|object<App\Traits\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69
70 1
        return $reservation;
71
    }
72
73
    public function deleteReservation(
74
        Reservation $reservation
75
    ): Reservation {
76
        $this->assertIsGranted($this->security, PermissionEnum::PARKING_RESERVATION_DELETE, $reservation);
0 ignored issues
show
Documentation introduced by
$reservation is of type object<App\Entity\Parking\Reservation>, but the function expects a null|object<App\Traits\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
78
        $this->reservationRepository->deleteAll($reservation);
79
80
        return $reservation;
81
    }
82
}
83