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

Notice::getBody()   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 notice model class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class Notice implements Model
20
{
21
    protected $body;
22
    protected $creationDate;
23
    protected $ownerUserId;
24
25 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...
26
    {
27
        $instance = new self();
28
        $instance
29
            ->setBody(array_key_exists('body', $data) ? $data['body'] : null)
30
            ->setCreationDate(array_key_exists('creation_date', $data)
31
                ? new \DateTimeImmutable('@' . $data['creation_date'])
32
                : null
33
            )
34
            ->setOwnerUserId(array_key_exists('owner_user_id', $data) ? $data['owner_user_id'] : null);
35
36
        return $instance;
37
    }
38
39
    public static function fromProperties($body, \DateTimeInterface $creationDate, $ownerUserId)
40
    {
41
        $instance = new self();
42
43
        $instance
44
            ->setBody($body)
45
            ->setCreationDate($creationDate)
46
            ->setOwnerUserId($ownerUserId);
47
48
        return $instance;
49
    }
50
51
52
    public function setBody($body)
53
    {
54
        $this->body = $body;
55
56
        return $this;
57
    }
58
59
    public function getBody()
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...
60
    {
61
        return $this->body;
62
    }
63
64
    public function setCreationDate(\DateTimeInterface $creationDate = null)
65
    {
66
        $this->creationDate = $creationDate;
67
68
        return $this;
69
    }
70
71
    public function getCreationDate()
72
    {
73
        return $this->creationDate;
74
    }
75
76
    public function setOwnerUserId($ownerUserId)
77
    {
78
        $this->ownerUserId = $ownerUserId;
79
80
        return $this;
81
    }
82
83
    public function getOwnerUserId()
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...
84
    {
85
        return $this->ownerUserId;
86
    }
87
}
88