Conditions | 12 |
Paths | 24 |
Total Lines | 57 |
Code Lines | 35 |
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 |
||
56 | public function process(InputInterface $input, OutputInterface $output) |
||
57 | { |
||
58 | $featuresPath = $input->getArgument('features'); |
||
59 | |||
60 | // Can't use 'behat.paths.base' since that's locked at this point to base folder (not module) |
||
61 | $pathSuffix = $this->container->getParameter('behat.silverstripe_extension.context.path_suffix'); |
||
62 | |||
63 | $currentModuleName = null; |
||
64 | $modules = \SS_ClassLoader::instance()->getManifest()->getModules(); |
||
65 | |||
66 | // get module specified in behat.yml |
||
67 | $currentModuleName = $this->container->getParameter('behat.silverstripe_extension.module'); |
||
68 | |||
69 | // get module from short notation if path starts from @ |
||
70 | if ($featuresPath && preg_match('/^\@([^\/\\\\]+)(.*)$/', $featuresPath, $matches)) { |
||
71 | $currentModuleName = $matches[1]; |
||
72 | // TODO Replace with proper module loader once AJShort's changes are merged into core |
||
73 | $currentModulePath = $modules[$currentModuleName]; |
||
74 | $featuresPath = str_replace( |
||
75 | '@'.$currentModuleName, |
||
76 | $currentModulePath.DIRECTORY_SEPARATOR.$pathSuffix, |
||
77 | $featuresPath |
||
78 | ); |
||
79 | // get module from provided features path |
||
80 | } elseif (!$currentModuleName && $featuresPath) { |
||
81 | $path = realpath(preg_replace('/\.feature\:.*$/', '.feature', $featuresPath)); |
||
82 | foreach ($modules as $moduleName => $modulePath) { |
||
83 | if (false !== strpos($path, realpath($modulePath))) { |
||
84 | $currentModuleName = $moduleName; |
||
85 | $currentModulePath = realpath($modulePath); |
||
86 | break; |
||
87 | } |
||
88 | } |
||
89 | $featuresPath = $currentModulePath.DIRECTORY_SEPARATOR.$pathSuffix.DIRECTORY_SEPARATOR.$featuresPath; |
||
90 | // if module is configured for profile and feature provided |
||
91 | } elseif ($currentModuleName && $featuresPath) { |
||
92 | $currentModulePath = $modules[$currentModuleName]; |
||
93 | $featuresPath = $currentModulePath.DIRECTORY_SEPARATOR.$pathSuffix.DIRECTORY_SEPARATOR.$featuresPath; |
||
94 | } |
||
95 | |||
96 | if ($input->getOption('namespace')) { |
||
97 | $namespace = $input->getOption('namespace'); |
||
98 | } else { |
||
99 | $namespace = ucfirst($currentModuleName); |
||
100 | } |
||
101 | |||
102 | if ($currentModuleName) { |
||
103 | $this->container |
||
104 | ->get('behat.silverstripe_extension.context.class_guesser') |
||
105 | // TODO Improve once modules can declare their own namespaces consistently |
||
106 | ->setNamespaceBase($namespace); |
||
107 | } |
||
108 | |||
109 | $this->container |
||
110 | ->get('behat.console.command') |
||
111 | ->setFeaturesPaths($featuresPath ? array($featuresPath) : array()); |
||
112 | } |
||
113 | } |
||
114 |