Conditions | 13 |
Paths | 256 |
Total Lines | 107 |
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 |
||
58 | public function execute(InputInterface $input, OutputInterface $output): void |
||
59 | { |
||
60 | $admin = $this->pool->getInstance($input->getArgument('admin')); |
||
|
|||
61 | |||
62 | $output->writeln('<comment>AdminBundle Information</comment>'); |
||
63 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'id', $admin->getCode())); |
||
64 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Admin', \get_class($admin))); |
||
65 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Model', $admin->getClass())); |
||
66 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Controller', $admin->getBaseControllerName())); |
||
67 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Model Manager', \get_class($admin->getModelManager()))); |
||
68 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Form Builder', \get_class($admin->getFormBuilder()))); |
||
69 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'Datagrid Builder', \get_class($admin->getDatagridBuilder()))); |
||
70 | $output->writeln(sprintf('<info>% -20s</info> : %s', 'List Builder', \get_class($admin->getListBuilder()))); |
||
71 | |||
72 | if ($admin->isChild()) { |
||
73 | $output->writeln(sprintf('<info>% -15s</info> : %s', 'Parent', $admin->getParent()->getCode())); |
||
74 | } |
||
75 | |||
76 | $output->writeln(''); |
||
77 | $output->writeln('<info>Routes</info>'); |
||
78 | foreach ($admin->getRoutes()->getElements() as $route) { |
||
79 | $output->writeln(sprintf(' - % -25s %s', $route->getDefault('_sonata_name'), $route->getPath())); |
||
80 | } |
||
81 | |||
82 | $output->writeln(''); |
||
83 | $output->writeln('<info>Datagrid Columns</info>'); |
||
84 | foreach ($admin->getListFieldDescriptions() as $name => $fieldDescription) { |
||
85 | $output->writeln(sprintf( |
||
86 | ' - % -25s % -15s % -15s', |
||
87 | $name, |
||
88 | $fieldDescription->getType(), |
||
89 | $fieldDescription->getTemplate() |
||
90 | )); |
||
91 | } |
||
92 | |||
93 | $output->writeln(''); |
||
94 | $output->writeln('<info>Datagrid Filters</info>'); |
||
95 | foreach ($admin->getFilterFieldDescriptions() as $name => $fieldDescription) { |
||
96 | $output->writeln(sprintf( |
||
97 | ' - % -25s % -15s % -15s', |
||
98 | $name, |
||
99 | $fieldDescription->getType(), |
||
100 | $fieldDescription->getTemplate() |
||
101 | )); |
||
102 | } |
||
103 | |||
104 | $output->writeln(''); |
||
105 | $output->writeln('<info>Form theme(s)</info>'); |
||
106 | foreach ($admin->getFormTheme() as $template) { |
||
107 | $output->writeln(sprintf(' - %s', $template)); |
||
108 | } |
||
109 | |||
110 | $output->writeln(''); |
||
111 | $output->writeln('<info>Form Fields</info>'); |
||
112 | foreach ($admin->getFormFieldDescriptions() as $name => $fieldDescription) { |
||
113 | $output->writeln(sprintf( |
||
114 | ' - % -25s % -15s % -15s', |
||
115 | $name, |
||
116 | $fieldDescription->getType(), |
||
117 | $fieldDescription->getTemplate() |
||
118 | )); |
||
119 | } |
||
120 | |||
121 | $metadata = $this->validator->getMetadataFor($admin->getClass()); |
||
122 | |||
123 | $output->writeln(''); |
||
124 | $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/3.0/book/validation.html'); |
||
125 | $output->writeln('<info>Properties constraints</info>'); |
||
126 | |||
127 | if (0 === \count($metadata->properties)) { |
||
128 | $output->writeln(' <error>no property constraints defined !!</error>'); |
||
129 | } else { |
||
130 | foreach ($metadata->properties as $name => $property) { |
||
131 | $output->writeln(sprintf(' - %s', $name)); |
||
132 | |||
133 | foreach ($property->getConstraints() as $constraint) { |
||
134 | $output->writeln(sprintf( |
||
135 | ' % -70s %s', |
||
136 | \get_class($constraint), |
||
137 | implode('|', $constraint->groups) |
||
138 | )); |
||
139 | } |
||
140 | } |
||
141 | } |
||
142 | |||
143 | $output->writeln(''); |
||
144 | $output->writeln('<info>Getters constraints</info>'); |
||
145 | |||
146 | if (0 === \count($metadata->getters)) { |
||
147 | $output->writeln(' <error>no getter constraints defined !!</error>'); |
||
148 | } else { |
||
149 | foreach ($metadata->getters as $name => $property) { |
||
150 | $output->writeln(sprintf(' - %s', $name)); |
||
151 | |||
152 | foreach ($property->getConstraints() as $constraint) { |
||
153 | $output->writeln(sprintf( |
||
154 | ' % -70s %s', |
||
155 | \get_class($constraint), |
||
156 | implode('|', $constraint->groups) |
||
157 | )); |
||
158 | } |
||
159 | } |
||
160 | } |
||
161 | |||
162 | $output->writeln(''); |
||
163 | $output->writeln('<info>done!</info>'); |
||
164 | } |
||
165 | } |
||
166 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.