| Total Lines | 70 |
| Code Lines | 42 |
| 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 declare(strict_types=1); |
||
| 66 | public function testSet($column, $value) |
||
| 67 | { |
||
| 68 | $object = $this->setTraitClass->set($column, $value); |
||
|
|
|||
| 69 | $this->assertObjectUsesTrait(BindTrait::class, $object); |
||
| 70 | $this->assertObjectUsesTrait(SetTrait::class, $object); |
||
| 71 | $this->assertEquals( |
||
| 72 | \array_merge( |
||
| 73 | static::SET_DEFAULT, |
||
| 74 | \array_reduce( |
||
| 75 | \array_map( |
||
| 76 | function ($column) { |
||
| 77 | return [ |
||
| 78 | $column => \sprintf( |
||
| 79 | '%s = :%s_Update', |
||
| 80 | $column, |
||
| 81 | \implode( |
||
| 82 | '_', |
||
| 83 | \array_map( |
||
| 84 | function ($columnPart) { |
||
| 85 | return \mb_convert_case($columnPart, MB_CASE_TITLE); |
||
| 86 | }, |
||
| 87 | \explode('.', $column) |
||
| 88 | ) |
||
| 89 | ) |
||
| 90 | ), |
||
| 91 | ]; |
||
| 92 | }, |
||
| 93 | [ |
||
| 94 | $column |
||
| 95 | ] |
||
| 96 | ), |
||
| 97 | 'array_merge', |
||
| 98 | [] |
||
| 99 | ) |
||
| 100 | ), |
||
| 101 | $this->setTraitClass->setData() |
||
| 102 | ); |
||
| 103 | $this->assertEquals( |
||
| 104 | \array_merge( |
||
| 105 | static::SET_BIND_DEFAULT, |
||
| 106 | \array_reduce( |
||
| 107 | \array_map( |
||
| 108 | function ($column, $value) { |
||
| 109 | return [ |
||
| 110 | \sprintf( |
||
| 111 | '%s_Update', |
||
| 112 | \implode( |
||
| 113 | '_', |
||
| 114 | \array_map( |
||
| 115 | function ($columnPart) { |
||
| 116 | return \mb_convert_case($columnPart, MB_CASE_TITLE); |
||
| 117 | }, |
||
| 118 | \explode('.', $column) |
||
| 119 | ) |
||
| 120 | ) |
||
| 121 | ) => $value, |
||
| 122 | ]; |
||
| 123 | }, |
||
| 124 | [ |
||
| 125 | $column |
||
| 126 | ], |
||
| 127 | [ |
||
| 128 | $value |
||
| 129 | ] |
||
| 130 | ), |
||
| 131 | 'array_merge', |
||
| 132 | [] |
||
| 133 | ) |
||
| 134 | ), |
||
| 135 | $this->setTraitClass->bindData() |
||
| 136 | ); |
||
| 204 |