Completed
Push — v2 ( e6c7b3...40717e )
by Beñat
06:35
created

AccountMerge::getMergeDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2014-2016 Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace BenatEspina\StackExchangeApiClient\Model;
13
14
/**
15
 * The account merge model class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class AccountMerge implements Model
20
{
21
    protected $mergeDate;
22
    protected $newAccountId;
23
    protected $oldAccountId;
24
25
    public static function fromProperties(\DateTimeInterface $mergeDate, $newAccountId, $oldAccountId)
26
    {
27
        $instance = new self();
28
        $instance
29
            ->setMergeDate($mergeDate)
30
            ->setNewAccountId($newAccountId)
31
            ->setOldAccountId($oldAccountId);
32
33
        return $instance;
34
    }
35
36 View Code Duplication
    public static function fromJson(array $data)
0 ignored issues
show
Duplication introduced by
This method 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...
37
    {
38
        $instance = new self();
39
        $instance
40
            ->setMergeDate(
41
                array_key_exists('merge_date', $data)
42
                    ? new \DateTimeImmutable('@' . $data['merge_date'])
43
                    : null
44
            )
45
            ->setNewAccountId(array_key_exists('new_account_id', $data) ? $data['new_account_id'] : null)
46
            ->setOldAccountId(array_key_exists('old_account_id', $data) ? $data['old_account_id'] : null);
47
48
        return $instance;
49
    }
50
51
    public function setMergeDate(\DateTimeInterface $mergeDate = null)
52
    {
53
        $this->mergeDate = $mergeDate;
54
55
        return $this;
56
    }
57
58
    public function getMergeDate()
59
    {
60
        return $this->mergeDate;
61
    }
62
63
    public function setNewAccountId($newAccountId)
64
    {
65
        $this->newAccountId = $newAccountId;
66
67
        return $this;
68
    }
69
70
    public function getNewAccountId()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
71
    {
72
        return $this->newAccountId;
73
    }
74
75
    public function setOldAccountId($oldAccountId)
76
    {
77
        $this->oldAccountId = $oldAccountId;
78
79
        return $this;
80
    }
81
82
    public function getOldAccountId()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
83
    {
84
        return $this->oldAccountId;
85
    }
86
}
87