We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 5 |
Paths | 6 |
Total Lines | 55 |
Code Lines | 32 |
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 |
||
47 | public function installTheme() |
||
48 | { |
||
49 | // Check if it is installed |
||
50 | if ($this->isInstalled()) { |
||
51 | $this->newLine(); |
||
|
|||
52 | $this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red'); |
||
53 | $this->newLine(); |
||
54 | |||
55 | return; |
||
56 | } |
||
57 | |||
58 | $this->newLine(); |
||
59 | $this->progressBlock($this->description); |
||
60 | |||
61 | // Require package |
||
62 | try { |
||
63 | $this->composerRequire(self::$addon['repo']); |
||
64 | $this->closeProgressBlock(); |
||
65 | } catch (\Throwable $e) { |
||
66 | $this->errorProgressBlock(); |
||
67 | $this->line(' '.$e->getMessage(), 'fg=red'); |
||
68 | $this->newLine(); |
||
69 | |||
70 | return; |
||
71 | } |
||
72 | |||
73 | // Display general error in case it failed |
||
74 | if (! $this->isInstalled()) { |
||
75 | $this->errorProgressBlock(); |
||
76 | $this->note('For further information please check the log file.'); |
||
77 | $this->note('You can also follow the manual installation process documented on GitHub.'); |
||
78 | $this->newLine(); |
||
79 | |||
80 | return; |
||
81 | } |
||
82 | |||
83 | // Publish the theme config file |
||
84 | $this->progressBlock('Publish theme config file'); |
||
85 | |||
86 | // manually include the provider in the run-time |
||
87 | if (! class_exists(self::$addon['provider'])) { |
||
88 | include self::$addon['provider_path'] ?? self::$addon['path'].'/src/AddonServiceProvider.php'; |
||
89 | app()->register(self::$addon['provider']); |
||
90 | } |
||
91 | |||
92 | $this->executeArtisanProcess('vendor:publish', [ |
||
93 | '--tag' => self::$addon['publish_tag'], |
||
94 | ]); |
||
95 | $this->closeProgressBlock(); |
||
96 | |||
97 | // add this theme's view namespace to the ui config file |
||
98 | $this->progressBlock('Use theme as view namespace in <fg=blue>config/backpack/ui.php</>'); |
||
99 | $this->useViewNamespaceInConfigFile(); |
||
100 | $this->closeProgressBlock(); |
||
101 | $this->newLine(); |
||
102 | } |
||
119 |