SingleBookingInMonth   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A load() 0 14 1
A getBooking() 0 4 1
1
<?php
2
3
namespace JhFlexiTimeTest\Fixture;
4
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\Persistence\ObjectManager;
7
use JhFlexiTime\Entity\Booking;
8
use JhUser\Entity\User;
9
use JhFlexiTime\DateTime\DateTime;
10
11
/**
12
 * Class SingleBookingInMonth
13
 * @package JhUserTest\Fixture
14
 * @author Aydin Hassan <[email protected]>
15
 */
16
class SingleBookingInMonth extends AbstractFixture
17
{
18
    /**
19
     * @var \DateTime
20
     */
21
    protected $date;
22
23
    /**
24
     * @var User
25
     */
26
    protected $user;
27
28
    /**
29
     * @var Booking
30
     */
31
    protected $booking;
32
33
    /**
34
     * @param User $user
35
     * @param DateTime $date
36
     */
37
    public function __construct(User $user, DateTime $date)
38
    {
39
        $this->user = $user;
40
        $this->date = $date;
41
    }
42
43
    /**
44
     * {inheritDoc}
45
     */
46
    public function load(ObjectManager $manager)
47
    {
48
        $manager->persist($this->user);
49
        $manager->flush();
50
51
        $booking = new Booking();
52
        $booking->setUser($this->user);
53
        $booking->setDate($this->date);
0 ignored issues
show
Compatibility introduced by
$this->date of type object<DateTime> is not a sub-type of object<JhFlexiTime\DateTime\DateTime>. It seems like you assume a child class of the class DateTime to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
54
        $manager->persist($booking);
55
56
        $manager->flush();
57
58
        $this->booking = $booking;
59
    }
60
61
    /**
62
     * @return Booking
63
     */
64
    public function getBooking()
65
    {
66
        return $this->booking;
67
    }
68
}
69