| Conditions | 5 | 
| Paths | 16 | 
| Total Lines | 54 | 
| Code Lines | 29 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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 | ||
| 76 | public function testModifierFailure() | ||
| 77 |     { | ||
| 78 |         if (!DB::get_conn()->supportsTransactions()) { | ||
| 79 | $this->markTestSkipped( | ||
| 80 | 'The Database doesn\'t support transactions.' | ||
| 81 | ); | ||
| 82 | } | ||
| 83 | |||
| 84 | Config::modify()->set( | ||
| 85 | Order::class, | ||
| 86 | 'modifiers', | ||
| 87 | [ | ||
| 88 | OrderModifierTest_TestModifier::class, | ||
| 89 | FlatTax::class | ||
| 90 | ] | ||
| 91 | ); | ||
| 92 | |||
| 93 | $order = $this->createOrder(); | ||
| 94 | $order->calculate(); | ||
| 95 | $order->write(); | ||
| 96 | |||
| 97 | // 408 from items + 10 from modifier + 25% from tax | ||
| 98 |         $this->assertEquals('522.5', $order->Total); | ||
| 99 | |||
| 100 | $amounts = array(); | ||
| 101 |         foreach ($order->Modifiers()->sort('Sort') as $modifier) { | ||
| 102 | $amounts[] = (string)$modifier->Amount; | ||
| 103 | } | ||
| 104 | |||
| 105 |         $this->assertEquals(array('10', '104.5'), $amounts); | ||
| 106 | |||
| 107 | OrderModifierTest_TestModifier::$value = 42; | ||
| 108 | |||
| 109 |         try { | ||
| 110 | // Calculate will now fail! | ||
| 111 | $order->calculate(); | ||
| 112 |         } catch (Exception $e) { | ||
| 113 | } | ||
| 114 | |||
| 115 | // reload order from DB | ||
| 116 | $order = Order::get()->byID($order->ID); | ||
| 117 | |||
| 118 | // Order Total should not have changed | ||
| 119 |         $this->assertEquals('522.5', $order->Total); | ||
| 120 | |||
| 121 | $amounts = array(); | ||
| 122 |         foreach ($order->Modifiers()->sort('Sort') as $modifier) { | ||
| 123 | $amounts[] = (string)$modifier->Amount; | ||
| 124 | } | ||
| 125 | |||
| 126 | $this->assertEquals( | ||
| 127 |             array('10', '104.5'), | ||
| 128 | $amounts, | ||
| 129 | 'Modifiers aren\'t allowed to change upon failure' | ||
| 130 | ); | ||
| 146 | 
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths