| Conditions | 11 |
| Paths | 7 |
| Total Lines | 30 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 8 | ||
| 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 |
||
| 22 | |||
| 23 | public const METHOD_PATTERN = '#^test[A-Z0-9_]#'; |
||
| 24 | |||
| 25 | protected SkipChecker $skipChecker; |
||
| 26 | protected ShouldFailChecker $shouldFailChecker; |
||
| 27 | protected DataProvider $dataProvider; |
||
| 28 | protected Reader $annotationsReader; |
||
| 29 | |||
| 30 | public function __construct() { |
||
| 31 | $this->annotationsReader = new Reader(); |
||
| 32 | $this->annotationsReader->registerEngine(new NetteReflectionEngine()); |
||
| 33 | $this->skipChecker = new SkipChecker($this->annotationsReader); |
||
| 34 | $this->shouldFailChecker = new ShouldFailChecker($this->annotationsReader); |
||
| 35 | $this->dataProvider = new DataProvider($this->annotationsReader); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get list of jobs with parameters for current test suit |
||
| 40 | * |
||
| 41 | * @return Job[] |
||
| 42 | */ |
||
| 43 | protected function getJobs(): array { |
||
| 44 | $jobs = []; |
||
| 45 | $r = new ReflectionClass(static::class); |
||
| 46 | $methods = array_values(preg_grep(static::METHOD_PATTERN, array_map(function(\ReflectionMethod $rm) { |
||
| 47 | return $rm->getName(); |
||
| 48 | }, $r->getMethods()))); |
||
| 49 | foreach($methods as $method) { |
||
| 50 | /** @var callable $callback */ |
||
| 51 | $callback = [$this, $method]; |
||
| 52 | $job = [ |
||
| 162 | ?> |