Completed
Push — master ( a95c92...e40b6a )
by Beñat
04:36
created

GenericIdTrait::setAnswerId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 6
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2015 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\Traits;
13
14
use BenatEspina\StackExchangeApiClient\Util\Util;
15
16
/**
17
 * Trait GenericIdTrait.
18
 *
19
 * @author Beñat Espiña <[email protected]>
20
 */
21 View Code Duplication
trait GenericIdTrait
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...
22
{
23
    /**
24
     * The answer id.
25
     *
26
     * @var int|null
27
     */
28
    protected $answerId;
29
30
    /**
31
     * The body.
32
     *
33
     * @var string|null
34
     */
35
    protected $body;
36
37
    /**
38
     * The question id.
39
     *
40
     * @var int|null
41
     */
42
    protected $questionId;
43
44
    /**
45
     * Sets the answer id.
46
     *
47
     * @param int $answerId The answer id
48
     *
49
     * @return $this self Object
50
     */
51
    public function setAnswerId($answerId)
52
    {
53
        $this->answerId = $answerId;
54
55
        return $this;
56
    }
57
58
    /**
59
     * Gets the answer id.
60
     *
61
     * @return int
62
     */
63
    public function getAnswerId()
64
    {
65
        return $this->answerId;
66
    }
67
68
    /**
69
     * Sets body.
70
     *
71
     * @param string|null $body The body
72
     *
73
     * @return $this self Object
74
     */
75
    public function setBody($body)
76
    {
77
        $this->body = $body;
78
79
        return $this;
80
    }
81
82
    /**
83
     * Gets body.
84
     *
85
     * @return string|null
86
     */
87
    public function getBody()
88
    {
89
        return $this->body;
90
    }
91
92
    /**
93
     * Sets the question id.
94
     *
95
     * @param int|null $questionId The question id
96
     *
97
     * @return $this self Object
98
     */
99
    public function setQuestionId($questionId)
100
    {
101
        $this->questionId = $questionId;
102
103
        return $this;
104
    }
105
106
    /**
107
     * Gets the question id.
108
     *
109
     * @return int|null
110
     */
111
    public function getQuestionId()
112
    {
113
        return $this->questionId;
114
    }
115
116
    /**
117
     * Loads the variables if the data exist into resource. It works like a constructor.
118
     *
119
     * @param null|mixed[] $resource The resource
120
     */
121
    protected function loadGenericId($resource)
122
    {
123
        $this->answerId = Util::setIfIntegerExists($resource, 'answer_id');
124
        $this->body = Util::setIfStringExists($resource, 'body');
125
        $this->questionId = Util::setIfIntegerExists($resource, 'question_id');
126
    }
127
}
128