Conditions | 9 |
Paths | 51 |
Total Lines | 91 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
67 | public function doPhase($story) |
||
68 | { |
||
69 | // shorthand |
||
70 | $st = $this->st; |
||
71 | $storyResult = $story->getResult(); |
||
72 | |||
73 | // our return value |
||
74 | $phaseResult = $this->getNewPhaseResult(); |
||
75 | |||
76 | try { |
||
77 | // do we have anything to do? |
||
78 | if (!$story->hasPreTestPrediction()) |
||
79 | { |
||
80 | $phaseResult->setContinuePlaying( |
||
81 | $phaseResult::HASNOACTIONS, |
||
82 | "story has no pre-test prediction instructions; skipping" |
||
83 | ); |
||
84 | return $phaseResult; |
||
85 | } |
||
86 | |||
87 | // setup the phase |
||
88 | $this->doPerPhaseSetup(); |
||
89 | |||
90 | // make the call |
||
91 | $callbacks = $story->getPreTestPrediction(); |
||
92 | |||
93 | foreach ($callbacks as $callback) { |
||
94 | if (is_callable($callback)) { |
||
95 | call_user_func($callback, $st); |
||
96 | } |
||
97 | } |
||
98 | |||
99 | // if we get here, the PreTestPrediction worked with |
||
100 | // no problems at all |
||
101 | $phaseResult->setContinuePlaying(); |
||
102 | } |
||
103 | // in any of the expects() calls in the preflight checks fails, |
||
104 | // an ActionFailedException will be thrown |
||
105 | catch (ActionFailedException $e) { |
||
|
|||
106 | $phaseResult->setContinuePlaying( |
||
107 | $phaseResult::FAILED, |
||
108 | $e->getMessage(), |
||
109 | $e |
||
110 | ); |
||
111 | $storyResult->setStoryShouldFail(); |
||
112 | } |
||
113 | catch (ExpectFailedException $e) { |
||
114 | $phaseResult->setContinuePlaying( |
||
115 | $phaseResult::FAILED, |
||
116 | $e->getMessage(), |
||
117 | $e |
||
118 | ); |
||
119 | $storyResult->setStoryShouldFail(); |
||
120 | } |
||
121 | // users can throw this to tell us that the story should fail |
||
122 | catch (StoryShouldFailException $e) { |
||
123 | $phaseResult->setContinuePlaying( |
||
124 | $phaseResult::FAILED, |
||
125 | $e->getMessage(), |
||
126 | $e |
||
127 | ); |
||
128 | $storyResult->setStoryShouldFail(); |
||
129 | } |
||
130 | // if any of the tests are incomplete, deal with that too |
||
131 | catch (NotImplementedException $e) { |
||
132 | $phaseResult->setPlayingFailed( |
||
133 | $phaseResult::INCOMPLETE, |
||
134 | $e->getMessage(), |
||
135 | $e |
||
136 | ); |
||
137 | $storyResult->setStoryIsIncomplete($phaseResult); |
||
138 | } |
||
139 | // deal with the things that go wrong |
||
140 | catch (Exception $e) { |
||
141 | $phaseResult->setPlayingFailed( |
||
142 | $phaseResult::ERROR, |
||
143 | $e->getMessage(), |
||
144 | $e |
||
145 | ); |
||
146 | $storyResult->setStoryHasError($phaseResult); |
||
147 | } |
||
148 | |||
149 | // close off any open log actions |
||
150 | $st->closeAllOpenActions(); |
||
151 | |||
152 | // tidy up after ourselves |
||
153 | $this->doPerPhaseTeardown(); |
||
154 | |||
155 | // all done |
||
156 | return $phaseResult; |
||
157 | } |
||
158 | } |
||
159 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.