1 | <?php |
||
20 | final class Result |
||
21 | { |
||
22 | /** |
||
23 | * @var Score The score |
||
24 | */ |
||
25 | private $score; |
||
26 | |||
27 | /** |
||
28 | * @var bool Indicates whether or not the attempt was successful |
||
29 | */ |
||
30 | private $success; |
||
31 | |||
32 | /** |
||
33 | * @var bool Indicates whether or not the Activity was completed |
||
34 | */ |
||
35 | private $completion; |
||
36 | |||
37 | /** |
||
38 | * @var string A response for the given Activity |
||
39 | */ |
||
40 | private $response; |
||
41 | |||
42 | /** |
||
43 | * @var string Period of time over which the Activity was performed |
||
44 | */ |
||
45 | private $duration; |
||
46 | |||
47 | /** |
||
48 | * @var Extensions|null Extensions associated with this result |
||
49 | */ |
||
50 | private $extensions; |
||
51 | |||
52 | /** |
||
53 | * @param Score|null $score |
||
54 | * @param bool|null $success |
||
55 | * @param bool|null $completion |
||
56 | * @param string|null $response |
||
57 | * @param string|null $duration |
||
58 | * @param Extensions|null $extensions |
||
59 | */ |
||
60 | public function __construct(Score $score = null, $success = null, $completion = null, $response = null, $duration = null, Extensions $extensions = null) |
||
69 | |||
70 | /** |
||
71 | * Returns the user's score. |
||
72 | * |
||
73 | * @return Score The score |
||
74 | */ |
||
75 | public function getScore() |
||
79 | |||
80 | /** |
||
81 | * Returns whether or not the user finished a task successfully. |
||
82 | * |
||
83 | * @return bool True if the user finished an exercise successfully, false |
||
84 | * otherwise |
||
85 | */ |
||
86 | public function getSuccess() |
||
90 | |||
91 | /** |
||
92 | * Returns the completion status. |
||
93 | * |
||
94 | * @return bool $completion True, if the Activity was completed, false |
||
95 | * otherwise |
||
96 | */ |
||
97 | public function getCompletion() |
||
101 | |||
102 | /** |
||
103 | * Returns the response. |
||
104 | * |
||
105 | * @return string The response |
||
106 | */ |
||
107 | public function getResponse() |
||
111 | |||
112 | /** |
||
113 | * Returns the period of time over which the Activity was performed. |
||
114 | * |
||
115 | * @return string The duration |
||
116 | */ |
||
117 | public function getDuration() |
||
121 | |||
122 | /** |
||
123 | * Returns the extensions associated with the result. |
||
124 | * |
||
125 | * @return Extensions|null The extensions |
||
126 | */ |
||
127 | public function getExtensions() |
||
131 | |||
132 | /** |
||
133 | * Checks if another result is equal. |
||
134 | * |
||
135 | * Two results are equal if and only if all of their properties are equal. |
||
136 | * |
||
137 | * @param Result $result The result to compare with |
||
138 | * |
||
139 | * @return bool True if the results are equal, false otherwise |
||
140 | */ |
||
141 | public function equals(Result $result) |
||
177 | } |
||
178 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: