UnitAvailabilityCalendar   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 92
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 92
loc 92
ccs 0
cts 41
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getCalendarDate() 12 12 3
A setCalendarDate() 5 5 1
A getAvailableForArrival() 4 4 1
A setAvailableForArrival() 5 5 1
A getAvailableForDeparture() 4 4 1
A setAvailableForDeparture() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Gueststream\PMS\IQWare\API;
4
5 View Code Duplication
class UnitAvailabilityCalendar
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
8
    /**
9
     * @var \DateTime $CalendarDate
10
     */
11
    protected $CalendarDate = null;
12
13
    /**
14
     * @var boolean $AvailableForArrival
15
     */
16
    protected $AvailableForArrival = null;
17
18
    /**
19
     * @var boolean $AvailableForDeparture
20
     */
21
    protected $AvailableForDeparture = null;
22
23
    /**
24
     * @param \DateTime $CalendarDate
25
     * @param boolean $AvailableForArrival
26
     * @param boolean $AvailableForDeparture
27
     */
28
    public function __construct(\DateTime $CalendarDate, $AvailableForArrival, $AvailableForDeparture)
29
    {
30
        $this->CalendarDate = $CalendarDate->format(\DateTime::ATOM);
0 ignored issues
show
Documentation Bug introduced by
It seems like $CalendarDate->format(\DateTime::ATOM) of type string is incompatible with the declared type object<DateTime> of property $CalendarDate.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
        $this->AvailableForArrival = $AvailableForArrival;
32
        $this->AvailableForDeparture = $AvailableForDeparture;
33
    }
34
35
    /**
36
     * @return \DateTime
37
     */
38
    public function getCalendarDate()
39
    {
40
        if ($this->CalendarDate == null) {
41
            return null;
42
        } else {
43
            try {
44
                return new \DateTime($this->CalendarDate);
45
            } catch (\Exception $e) {
46
                return false;
47
            }
48
        }
49
    }
50
51
    /**
52
     * @param \DateTime $CalendarDate
53
     * @return \Gueststream\PMS\IQWare\API\UnitAvailabilityCalendar
54
     */
55
    public function setCalendarDate(\DateTime $CalendarDate)
56
    {
57
        $this->CalendarDate = $CalendarDate->format(\DateTime::ATOM);
0 ignored issues
show
Documentation Bug introduced by
It seems like $CalendarDate->format(\DateTime::ATOM) of type string is incompatible with the declared type object<DateTime> of property $CalendarDate.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
58
        return $this;
59
    }
60
61
    /**
62
     * @return boolean
63
     */
64
    public function getAvailableForArrival()
65
    {
66
        return $this->AvailableForArrival;
67
    }
68
69
    /**
70
     * @param boolean $AvailableForArrival
71
     * @return \Gueststream\PMS\IQWare\API\UnitAvailabilityCalendar
72
     */
73
    public function setAvailableForArrival($AvailableForArrival)
74
    {
75
        $this->AvailableForArrival = $AvailableForArrival;
76
        return $this;
77
    }
78
79
    /**
80
     * @return boolean
81
     */
82
    public function getAvailableForDeparture()
83
    {
84
        return $this->AvailableForDeparture;
85
    }
86
87
    /**
88
     * @param boolean $AvailableForDeparture
89
     * @return \Gueststream\PMS\IQWare\API\UnitAvailabilityCalendar
90
     */
91
    public function setAvailableForDeparture($AvailableForDeparture)
92
    {
93
        $this->AvailableForDeparture = $AvailableForDeparture;
94
        return $this;
95
    }
96
}
97