1 | <?php |
||
20 | final class Result |
||
21 | { |
||
22 | private $score; |
||
23 | private $success; |
||
24 | private $completion; |
||
25 | private $response; |
||
26 | private $duration; |
||
27 | private $extensions; |
||
28 | |||
29 | public function __construct(Score $score = null, bool $success = null, bool $completion = null, string $response = null, string $duration = null, Extensions $extensions = null) |
||
38 | |||
39 | public function withScore(Score $score = null): self |
||
46 | |||
47 | public function withSuccess(bool $success = null): self |
||
54 | |||
55 | public function withCompletion(bool $completion = null): self |
||
62 | |||
63 | public function withResponse(string $response = null): self |
||
70 | |||
71 | public function withDuration(string $duration = null): self |
||
78 | |||
79 | public function withExtensions(Extensions $extensions = null): self |
||
86 | |||
87 | /** |
||
88 | * Returns the user's score. |
||
89 | */ |
||
90 | public function getScore(): ?Score |
||
94 | |||
95 | /** |
||
96 | * Returns whether or not the user finished a task successfully. |
||
97 | */ |
||
98 | public function getSuccess(): ?bool |
||
102 | |||
103 | /** |
||
104 | * Returns the completion status. |
||
105 | */ |
||
106 | public function getCompletion(): ?bool |
||
110 | |||
111 | /** |
||
112 | * Returns the response. |
||
113 | */ |
||
114 | public function getResponse(): ?string |
||
118 | |||
119 | /** |
||
120 | * Returns the period of time over which the Activity was performed. |
||
121 | */ |
||
122 | public function getDuration(): ?string |
||
126 | |||
127 | /** |
||
128 | * Returns the extensions associated with the result. |
||
129 | */ |
||
130 | public function getExtensions(): ?Extensions |
||
134 | |||
135 | /** |
||
136 | * Checks if another result is equal. |
||
137 | * |
||
138 | * Two results are equal if and only if all of their properties are equal. |
||
139 | */ |
||
140 | public function equals(Result $result): bool |
||
176 | } |
||
177 |
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: