| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 31 |
| 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 |
||
| 80 | public function testFromArray() |
||
| 81 | { |
||
| 82 | /** @var Builder $builder */ |
||
| 83 | $builder = $this->app->makeWith(Builder::class, [ |
||
| 84 | 'attributes' => new Attributes(['class' => 'menu']), |
||
| 85 | 'activeAttributes' => new Attributes(['class' => 'active']), |
||
| 86 | ]); |
||
| 87 | |||
| 88 | $builder->create('index', Link::class, function(LinkFactory $factory) { |
||
| 89 | $factory->title = 'Index'; |
||
| 90 | $factory->url = '/'; |
||
| 91 | |||
| 92 | return $factory->build(); |
||
| 93 | }); |
||
| 94 | |||
| 95 | $builder->create('deliver_1', Text::class, function(TextFactory $factory) { |
||
| 96 | $factory->text = null; |
||
| 97 | $factory->attributes->put('class', 'deliver'); |
||
| 98 | |||
| 99 | return $factory->build(); |
||
| 100 | }); |
||
| 101 | |||
| 102 | $builder->create('settings', SubMenu::class, function(SubMenuFactory $factory) { |
||
| 103 | $factory->title = 'Index'; |
||
| 104 | $factory->builder->create('some', Link::class, function(LinkFactory $factory) { |
||
| 105 | $factory->title = 'Some setting'; |
||
| 106 | $factory->url = '/settings/some'; |
||
| 107 | |||
| 108 | return $factory->build(); |
||
| 109 | }); |
||
| 110 | |||
| 111 | return $factory->build(); |
||
| 112 | }); |
||
| 113 | |||
| 114 | $builder->create('deliver_2', Text::class, function(TextFactory $factory) { |
||
| 115 | $factory->text = null; |
||
| 116 | $factory->attributes->put('class', 'deliver'); |
||
| 117 | |||
| 118 | return $factory->build(); |
||
| 119 | }); |
||
| 120 | |||
| 121 | $builder->create('logout', Link::class, function(LinkFactory $factory) { |
||
| 122 | $factory->title = 'Logout'; |
||
| 123 | $factory->url = '/logout'; |
||
| 124 | |||
| 125 | return $factory->build(); |
||
| 126 | }); |
||
| 127 | |||
| 128 | /** @var Menu $menu */ |
||
| 129 | $menu = $this->app->make(Menu::class); |
||
| 130 | $menu->fromArray('from_array', $builder->toArray()); |
||
| 131 | |||
| 132 | $this->assertEquals($builder->render(), $menu->get('from_array')->render()); |
||
| 133 | $this->assertEquals($builder->toArray(), $menu->toArray('from_array')); |
||
| 134 | } |
||
| 135 | |||
| 141 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.