Code Duplication    Length = 75-75 lines in 2 locations

src/Model/Traits/BetaDateTrait.php 1 location

@@ 21-95 (lines=75) @@
18
 *
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
trait BetaDateTrait
22
{
23
    /**
24
     * Closed beta date.
25
     *
26
     * @var \DateTime|null
27
     */
28
    protected $closedBetaDate;
29
30
    /**
31
     * Open beta date.
32
     *
33
     * @var \DateTime|null
34
     */
35
    protected $openBetaDate;
36
37
    /**
38
     * Sets closed beta date.
39
     *
40
     * @param \DateTime $closedBetaDate The closed beta date.
41
     *
42
     * @return $this self Object
43
     */
44
    public function setClosedBetaDate(\DateTime $closedBetaDate)
45
    {
46
        $this->closedBetaDate = $closedBetaDate;
47
48
        return $this;
49
    }
50
51
    /**
52
     * Gets closed beta date.
53
     *
54
     * @return \DateTime|null
55
     */
56
    public function getClosedBetaDate()
57
    {
58
        return $this->closedBetaDate;
59
    }
60
61
    /**
62
     * Sets open beta date.
63
     *
64
     * @param \DateTime $openBetaDate The open beta date.
65
     *
66
     * @return $this self Object
67
     */
68
    public function setOpenBetaDate(\DateTime $openBetaDate)
69
    {
70
        $this->openBetaDate = $openBetaDate;
71
72
        return $this;
73
    }
74
75
    /**
76
     * Gets open beta date.
77
     *
78
     * @return \DateTime|null
79
     */
80
    public function getOpenBetaDate()
81
    {
82
        return $this->openBetaDate;
83
    }
84
85
    /**
86
     * Loads the variables if the data exist into resource. It works like a constructor.
87
     *
88
     * @param null|mixed[] $resource The resource
89
     */
90
    protected function loadBetaDate($resource)
91
    {
92
        $this->closedBetaDate = Util::setIfDateTimeExists($resource, 'closed_beta_date');
93
        $this->openBetaDate = Util::setIfDateTimeExists($resource, 'open_beta_date');
94
    }
95
}
96

src/Model/Traits/EditTrait.php 1 location

@@ 23-97 (lines=75) @@
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
trait EditTrait
24
{
25
    /**
26
     * Last edit date.
27
     *
28
     * @var \DateTime|null
29
     */
30
    protected $lastEditDate;
31
32
    /**
33
     * Last editor.
34
     *
35
     * @var \BenatEspina\StackExchangeApiClient\Model\Interfaces\ShallowUserInterface
36
     */
37
    protected $lastEditor;
38
39
    /**
40
     * Sets last edit date.
41
     *
42
     * @param \DateTime|null $lastEditDate The last edit date
43
     *
44
     * @return $this self Object
45
     */
46
    public function setLastEditDate(\DateTime $lastEditDate)
47
    {
48
        $this->lastEditDate = $lastEditDate;
49
50
        return $this;
51
    }
52
53
    /**
54
     * Gets last edit date.
55
     *
56
     * @return \DateTime|null
57
     */
58
    public function getLastEditDate()
59
    {
60
        return $this->lastEditDate;
61
    }
62
63
    /**
64
     * Sets last editor.
65
     *
66
     * @param \BenatEspina\StackExchangeApiClient\Model\Interfaces\ShallowUserInterface $lastEditor The last editor.
67
     *
68
     * @return $this self Object
69
     */
70
    public function setLastEditor(ShallowUserInterface $lastEditor)
71
    {
72
        $this->lastEditor = $lastEditor;
73
74
        return $this;
75
    }
76
77
    /**
78
     * Gets last editor.
79
     *
80
     * @return \BenatEspina\StackExchangeApiClient\Model\Interfaces\ShallowUserInterface
81
     */
82
    public function getLastEditor()
83
    {
84
        return $this->lastEditor;
85
    }
86
87
    /**
88
     * Loads the variables if the data exist into resource. It works like a constructor.
89
     *
90
     * @param null|mixed[] $resource The resource
91
     */
92
    protected function loadEdit($resource)
93
    {
94
        $this->lastEditDate = Util::setIfDateTimeExists($resource, 'last_edit_date');
95
        $this->lastEditor = new ShallowUser(Util::setIfArrayExists($resource, 'last_editor'));
96
    }
97
}
98