Conditions | 6 |
Paths | 32 |
Total Lines | 54 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
56 | public function wire(ContainerInterface $dic) |
||
57 | { |
||
58 | $this->setDic($dic); |
||
59 | if (empty($dic['Yapeal.Config.Yaml'])) { |
||
60 | $dic['Yapeal.Config.Yaml'] = $dic->factory(function () { |
||
61 | return new YamlConfigFile(); |
||
62 | }); |
||
63 | } |
||
64 | $path = dirname(str_replace('\\', '/', __DIR__), 2) . '/'; |
||
65 | // These two paths are critical to Yapeal-ng working and can't be overridden. |
||
66 | $dic['Yapeal.baseDir'] = $path; |
||
67 | $dic['Yapeal.libDir'] = $path . 'lib/'; |
||
68 | $configFiles = [str_replace('\\', '/', __DIR__) . '/yapealDefaults.yaml']; |
||
69 | $settings = []; |
||
70 | /** |
||
71 | * Do to the importance that the cache/ and log/ directories and the main configuration file _not_ point to |
||
72 | * somewhere under Composer's vendor/ directory they are now forced to use either vendor parent directory or |
||
73 | * Yapeal-ng's base directory depending on if Yapeal-ng finds itself under a vendor/ directory. |
||
74 | * |
||
75 | * If as an application developer you wish to use a different directory than cache/ or log/ in your |
||
76 | * application's root directory you __MUST__ set the 'Yapeal.FileSystem.Cache.dir' and/or 'Yapeal.Log.dir' |
||
77 | * setting(s) of the Container before you give it to the Wiring class to prevent them being changed here when |
||
78 | * Wiring::wireAll() calls this class method during wireAll()'s normal processing. On the command line you have |
||
79 | * the -c or --configFile option to override the settings as well. |
||
80 | * |
||
81 | * Read the existing [Configuration Files](../../docs/config/ConfigurationFiles.md) docs for more about how to |
||
82 | * override the optional config/yapeal.yaml file as well. |
||
83 | */ |
||
84 | if (false !== $vendorPos = strpos($path, 'vendor/')) { |
||
85 | $dic['Yapeal.vendorParentDir'] = substr($path, 0, $vendorPos); |
||
86 | $configFiles[] = $dic['Yapeal.vendorParentDir'] . 'config/yapeal.yaml'; |
||
87 | $settings['Yapeal.FileSystem.Cache.dir'] = '{Yapeal.vendorParentDir}cache/'; |
||
88 | $settings['Yapeal.Log.dir'] = '{Yapeal.vendorParentDir}log/'; |
||
89 | } else { |
||
90 | $configFiles[] = $path . 'config/yapeal.yaml'; |
||
91 | $settings['Yapeal.FileSystem.Cache.dir'] = $path . 'cache/'; |
||
92 | $settings['Yapeal.Log.dir'] = $path . 'log/'; |
||
93 | } |
||
94 | if (!empty($dic['Yapeal.Config.configFile'])) { |
||
95 | $configFiles[] = $dic['Yapeal.Config.configFile']; |
||
96 | unset($dic['Yapeal.Config.configFile']); |
||
97 | } |
||
98 | // Process each file in turn so any substitutions are done in a more |
||
99 | // consistent way. |
||
100 | foreach ($configFiles as $configFile) { |
||
101 | $settings = $this->parserConfigFile($configFile, $settings); |
||
102 | } |
||
103 | $settings = $this->gitVersionSetting($settings); |
||
104 | $settings = $this->doSubstitutions($settings, $dic); |
||
105 | $additions = array_diff(array_keys($settings), $dic->keys()); |
||
106 | foreach ($additions as $add) { |
||
107 | $dic[$add] = $settings[$add]; |
||
108 | } |
||
109 | } |
||
110 | /** |
||
125 |