File tree Expand file tree Collapse file tree 12 files changed +68
-10
lines changed Expand file tree Collapse file tree 12 files changed +68
-10
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,10 @@ public function setUrl(string $url): self
5656
5757 public function getMethod (): string
5858 {
59- return $ this ->options ['method ' ] ?? 'GET ' ;
59+ return is_string (value: $ this ->options ['method ' ])
60+ ? $ this ->options ['method ' ]
61+ : 'GET '
62+ ;
6063 }
6164
6265 public function setMethod (string $ method ): self
@@ -71,7 +74,10 @@ public function setMethod(string $method): self
7174 */
7275 public function getClientOptions (): array
7376 {
74- return is_array (value: $ this ->options ['client_options ' ]) ? $ this ->options ['client_options ' ] : [];
77+ return is_array (value: $ this ->options ['client_options ' ])
78+ ? $ this ->options ['client_options ' ]
79+ : []
80+ ;
7581 }
7682
7783 /**
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ public function toString(): string
3131 */
3232 protected function matches ($ other ): bool
3333 {
34+ if (!$ other instanceof ProbeInterface) {
35+ return false ;
36+ }
37+
3438 return $ this ->expectedCount === $ other ->getExecutedTasks ();
3539 }
3640}
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ public function toString(): string
3131 */
3232 protected function matches ($ other ): bool
3333 {
34+ if (!$ other instanceof ProbeInterface) {
35+ return false ;
36+ }
37+
3438 return $ this ->expectedCount === $ other ->getFailedTasks ();
3539 }
3640}
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ public function toString(): string
3131 */
3232 protected function matches ($ other ): bool
3333 {
34+ if (!$ other instanceof ProbeInterface) {
35+ return false ;
36+ }
37+
3438 return $ this ->expectedCount === $ other ->getScheduledTasks ();
3539 }
3640}
Original file line number Diff line number Diff line change 77use PHPUnit \Framework \Constraint \Constraint ;
88use SchedulerBundle \Probe \ProbeInterface ;
99
10+ use Throwable ;
1011use function json_encode ;
1112use function sprintf ;
1213
@@ -32,9 +33,14 @@ public function toString(): string
3233
3334 /**
3435 * @param mixed|ProbeInterface $other
36+ * @throws Throwable {@see ProbeInterface::getScheduledTasks()}
3537 */
3638 protected function matches ($ other ): bool
3739 {
40+ if (!$ other instanceof ProbeInterface) {
41+ return false ;
42+ }
43+
3844 return $ this ->expectedState === [
3945 'executedTasks ' => $ other ->getExecutedTasks (),
4046 'failedTasks ' => $ other ->getFailedTasks (),
Original file line number Diff line number Diff line change 77use PHPUnit \Framework \Constraint \Constraint ;
88use SchedulerBundle \SchedulerInterface ;
99
10+ use Throwable ;
1011use function sprintf ;
1112
1213/**
@@ -28,9 +29,16 @@ public function toString(): string
2829
2930 /**
3031 * @param mixed|SchedulerInterface $other
32+ * @throws Throwable {@see SchedulerInterface::getDueTasks()}
3133 */
3234 protected function matches ($ other ): bool
3335 {
34- return $ this ->expectedCount === $ other ->getDueTasks ()->count ();
36+ if (!$ other instanceof SchedulerInterface) {
37+ return false ;
38+ }
39+
40+ $ dueTasks = $ other ->getDueTasks ();
41+
42+ return $ this ->expectedCount === $ dueTasks ->count ();
3543 }
3644}
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ public function toString(): string
3333 */
3434 protected function matches ($ other ): bool
3535 {
36+ if (!$ other instanceof TaskEventList) {
37+ return false ;
38+ }
39+
3640 return $ this ->expectedCount === $ this ->countExecutedTasks ($ other );
3741 }
3842
@@ -44,7 +48,9 @@ private function countExecutedTasks(TaskEventList $taskEventList): int
4448 continue ;
4549 }
4650
47- if (TaskInterface::SUCCEED !== $ taskEvent ->getTask ()->getExecutionState ()) {
51+ $ task = $ taskEvent ->getTask ();
52+
53+ if (TaskInterface::SUCCEED !== $ task ->getExecutionState ()) {
4854 continue ;
4955 }
5056
Original file line number Diff line number Diff line change 88use SchedulerBundle \Event \TaskEventList ;
99
1010use function count ;
11- use function is_countable ;
1211use function sprintf ;
1312
1413/**
@@ -33,6 +32,10 @@ public function toString(): string
3332 */
3433 protected function matches ($ other ): bool
3534 {
36- return $ this ->expectedCount === (is_countable ($ other ->getFailedTaskEvents ()) ? count ($ other ->getFailedTaskEvents ()) : 0 );
35+ if (!$ other instanceof TaskEventList) {
36+ return false ;
37+ }
38+
39+ return $ this ->expectedCount === count ($ other ->getFailedTaskEvents ());
3740 }
3841}
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ public function toString(): string
3232 */
3333 protected function matches ($ other ): bool
3434 {
35+ if (!$ other instanceof TaskEventList) {
36+ return false ;
37+ }
38+
3539 return $ this ->expectedCount === $ this ->countQueuedTasks ($ other );
3640 }
3741
@@ -43,7 +47,9 @@ private function countQueuedTasks(TaskEventList $taskEventList): int
4347 continue ;
4448 }
4549
46- if (!$ taskEvent ->getTask ()->isQueued ()) {
50+ $ task = $ taskEvent ->getTask ();
51+
52+ if (!$ task ->isQueued ()) {
4753 continue ;
4854 }
4955
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ public function toString(): string
3232 */
3333 protected function matches ($ other ): bool
3434 {
35- return $ this ->expectedCount === (is_countable ($ other ->getScheduledTaskEvents ()) ? count ($ other ->getScheduledTaskEvents ()) : 0 );
35+ if (!$ other instanceof TaskEventList) {
36+ return false ;
37+ }
38+
39+ return $ this ->expectedCount === count ($ other ->getScheduledTaskEvents ());
3640 }
3741}
You can’t perform that action at this time.
0 commit comments