RoomCalendarBreakdown   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 67
loc 67
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getCalendarDate() 12 12 3
A setCalendarDate() 5 5 1
A getAvailable() 4 4 1
A setAvailable() 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 RoomCalendarBreakdown
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 $Available
15
     */
16
    protected $Available = null;
17
18
    /**
19
     * @param \DateTime $CalendarDate
20
     * @param boolean $Available
21
     */
22
    public function __construct(\DateTime $CalendarDate, $Available)
23
    {
24
        $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...
25
        $this->Available = $Available;
26
    }
27
28
    /**
29
     * @return \DateTime
30
     */
31
    public function getCalendarDate()
32
    {
33
        if ($this->CalendarDate == null) {
34
            return null;
35
        } else {
36
            try {
37
                return new \DateTime($this->CalendarDate);
38
            } catch (\Exception $e) {
39
                return false;
40
            }
41
        }
42
    }
43
44
    /**
45
     * @param \DateTime $CalendarDate
46
     * @return \Gueststream\PMS\IQWare\API\RoomCalendarBreakdown
47
     */
48
    public function setCalendarDate(\DateTime $CalendarDate)
49
    {
50
        $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...
51
        return $this;
52
    }
53
54
    /**
55
     * @return boolean
56
     */
57
    public function getAvailable()
58
    {
59
        return $this->Available;
60
    }
61
62
    /**
63
     * @param boolean $Available
64
     * @return \Gueststream\PMS\IQWare\API\RoomCalendarBreakdown
65
     */
66
    public function setAvailable($Available)
67
    {
68
        $this->Available = $Available;
69
        return $this;
70
    }
71
}
72