Conditions | 2 |
Total Lines | 106 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 declare(strict_types=1); |
||
36 | $this->entity = MockEntityFactory::createMockEntity(); |
||
37 | throw new ValidationException($this->errors, $this->entity); |
||
38 | } catch (ValidationException $e) { |
||
39 | $this->exception = $e; |
||
40 | } |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @test |
||
45 | * @small |
||
46 | * @covers ::getInvalidEntity |
||
47 | */ |
||
48 | public function getInvalidEntity(): void |
||
49 | { |
||
50 | $expected = $this->entity; |
||
51 | $actual = $this->exception->getInvalidEntity(); |
||
52 | self::assertSame($expected, $actual); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @test |
||
57 | * @small |
||
58 | * @covers ::getValidationErrors |
||
59 | */ |
||
60 | public function getValidationErrors(): void |
||
61 | { |
||
62 | $expected = $this->errors; |
||
63 | $actual = $this->exception->getValidationErrors(); |
||
64 | self::assertSame($expected, $actual); |
||
65 | } |
||
66 | } |
||
67 |