Conditions | 11 |
Paths | 7 |
Total Lines | 30 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 0 | Features | 1 |
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 |
||
26 | protected DataProvider $dataProvider; |
||
27 | protected Reader $annotationsReader; |
||
28 | |||
29 | public function __construct() { |
||
30 | $this->annotationsReader = new Reader(); |
||
31 | $this->annotationsReader->registerEngine(new NetteReflectionEngine()); |
||
32 | $this->skipChecker = new SkipChecker($this->annotationsReader); |
||
33 | $this->shouldFailChecker = new ShouldFailChecker($this->annotationsReader); |
||
34 | $this->dataProvider = new DataProvider($this->annotationsReader); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Get list of jobs with parameters for current test suit |
||
39 | * |
||
40 | * @return Job[] |
||
41 | */ |
||
42 | protected function getJobs(): array { |
||
43 | $jobs = []; |
||
44 | $r = new \ReflectionClass(static::class); |
||
45 | $methods = array_values(preg_grep(static::METHOD_PATTERN, array_map(function(\ReflectionMethod $rm) { |
||
46 | return $rm->getName(); |
||
47 | }, $r->getMethods()))); |
||
48 | foreach($methods as $method) { |
||
49 | /** @var callable $callback */ |
||
50 | $callback = [$this, $method]; |
||
51 | $job = [ |
||
52 | "name" => $this->getJobName(static::class, $method), |
||
53 | "callback" => $callback, |
||
54 | "params" => [], |
||
55 | "skip" => $this->skipChecker->shouldSkip(static::class, $method), |
||
56 | "shouldFail" => $this->shouldFailChecker->shouldFail(static::class, $method), |
||
161 | ?> |