| Conditions | 5 |
| Paths | 8 |
| Total Lines | 57 |
| Code Lines | 34 |
| 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 |
||
| 53 | public function wire(ContainerInterface $dic) |
||
| 54 | { |
||
| 55 | if (empty($dic['Yapeal.Xsd.Creator'])) { |
||
| 56 | $dic['Yapeal.Xsd.Creator'] = $dic->factory( |
||
| 57 | function ($dic) { |
||
| 58 | $loader = new Twig_Loader_Filesystem($dic['Yapeal.Xsd.dir']); |
||
| 59 | $twig = new Twig_Environment( |
||
| 60 | $loader, ['debug' => true, 'strict_variables' => true, 'autoescape' => false] |
||
| 61 | ); |
||
| 62 | $filter = new Twig_SimpleFilter( |
||
| 63 | 'ucFirst', function ($value) { |
||
| 64 | return ucfirst($value); |
||
| 65 | } |
||
| 66 | ); |
||
| 67 | $twig->addFilter($filter); |
||
| 68 | $filter = new Twig_SimpleFilter( |
||
| 69 | 'lcFirst', function ($value) { |
||
| 70 | return lcfirst($value); |
||
| 71 | } |
||
| 72 | ); |
||
| 73 | $twig->addFilter($filter); |
||
| 74 | /** |
||
| 75 | * @var \Yapeal\Xsd\Creator $create |
||
| 76 | */ |
||
| 77 | $create = new $dic['Yapeal.Xsd.create']($twig, $dic['Yapeal.Xsd.dir']); |
||
| 78 | if (array_key_exists('Yapeal.Create.overwrite', $dic)) { |
||
| 79 | $create->setOverwrite($dic['Yapeal.Create.overwrite']); |
||
| 80 | } |
||
| 81 | return $create; |
||
| 82 | } |
||
| 83 | ); |
||
| 84 | } |
||
| 85 | if (empty($dic['Yapeal.Xsd.Validator'])) { |
||
| 86 | $dic['Yapeal.Xsd.Validator'] = $dic->factory( |
||
| 87 | function ($dic) { |
||
| 88 | return new $dic['Yapeal.Xsd.validate']($dic['Yapeal.Xsd.dir']); |
||
| 89 | } |
||
| 90 | ); |
||
| 91 | } |
||
| 92 | if (!isset($dic['Yapeal.Event.Mediator'])) { |
||
| 93 | $mess = 'Tried to call Mediator before it has been added'; |
||
| 94 | throw new \LogicException($mess); |
||
| 95 | } |
||
| 96 | /** |
||
| 97 | * @var \Yapeal\Event\MediatorInterface $mediator |
||
| 98 | */ |
||
| 99 | $mediator = $dic['Yapeal.Event.Mediator']; |
||
| 100 | $mediator->addServiceSubscriberByEventList( |
||
| 101 | 'Yapeal.Xsd.Creator', |
||
| 102 | ['Yapeal.EveApi.create' => ['createXsd', 'last']] |
||
| 103 | ); |
||
| 104 | $mediator->addServiceSubscriberByEventList( |
||
| 105 | 'Yapeal.Xsd.Validator', |
||
| 106 | ['Yapeal.EveApi.validate' => ['validateEveApi', 'last']] |
||
| 107 | ); |
||
| 108 | return $this; |
||
| 109 | } |
||
| 110 | } |
||
| 111 |