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

RequiresTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 107
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setRequiresComment() 0 6 1
A isRequiresComment() 0 4 1
A setRequiresQuestionId() 0 6 1
A isRequiresQuestionId() 0 4 1
A setRequiresSite() 0 6 1
A isRequiresSite() 0 4 1
A loadAnswered() 0 6 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 RequiresTrait.
18
 *
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
trait RequiresTrait
22
{
23
    /**
24
     * Boolean that shows if comment is required or not.
25
     *
26
     * @var bool|null
27
     */
28
    protected $requiresComment;
29
30
    /**
31
     * Boolean that shows if question id is required or not.
32
     *
33
     * @var bool|null
34
     */
35
    protected $requiresQuestionId;
36
37
    /**
38
     * Boolean that shows if site id is required or not.
39
     *
40
     * @var bool|null
41
     */
42
    protected $requiresSite;
43
44
    /**
45
     * Sets requires comment.
46
     *
47
     * @param bool|null $requiresComment The requires comment boolean
48
     *
49
     * @return $this self Object
50
     */
51
    public function setRequiresComment($requiresComment)
52
    {
53
        $this->requiresComment = $requiresComment;
54
55
        return $this;
56
    }
57
58
    /**
59
     * Gets requires comment.
60
     *
61
     * @return bool|null
62
     */
63
    public function isRequiresComment()
64
    {
65
        return $this->requiresComment;
66
    }
67
68
    /**
69
     * Sets requires question id.
70
     *
71
     * @param bool|null $requiresQuestionId The requires question id boolean
72
     *
73
     * @return $this self Object
74
     */
75
    public function setRequiresQuestionId($requiresQuestionId)
76
    {
77
        $this->requiresQuestionId = $requiresQuestionId;
78
79
        return $this;
80
    }
81
82
    /**
83
     * Gets requires question id.
84
     *
85
     * @return bool|null
86
     */
87
    public function isRequiresQuestionId()
88
    {
89
        return $this->requiresQuestionId;
90
    }
91
92
    /**
93
     * Sets requires site.
94
     *
95
     * @param bool|null $requiresSite The requires site boolean
96
     *
97
     * @return $this self Object
98
     */
99
    public function setRequiresSite($requiresSite)
100
    {
101
        $this->requiresSite = $requiresSite;
102
103
        return $this;
104
    }
105
106
    /**
107
     * Gets requires site.
108
     *
109
     * @return bool|null
110
     */
111
    public function isRequiresSite()
112
    {
113
        return $this->requiresSite;
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 loadAnswered($resource)
122
    {
123
        $this->requiresComment = Util::setIfBoolExists($resource, 'requires_comment');
124
        $this->requiresQuestionId = Util::setIfBoolExists($resource, 'requires_question_id');
125
        $this->requiresSite = Util::setIfBoolExists($resource, 'requires_site');
126
    }
127
}
128