zaherkhirullah /
laravel-helpers
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Hayrullah\Helpers; |
||||||
| 4 | |||||||
| 5 | use Illuminate\Support\ServiceProvider; |
||||||
| 6 | use Illuminate\Support\Str; |
||||||
| 7 | |||||||
| 8 | class HelperServiceProvider extends ServiceProvider |
||||||
| 9 | { |
||||||
| 10 | protected $HELPERS_PATH = 'Helpers/'; |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * Register services. |
||||||
| 14 | * |
||||||
| 15 | * @return void |
||||||
| 16 | */ |
||||||
| 17 | public function register() |
||||||
| 18 | { |
||||||
| 19 | $this->registerHelpers(); |
||||||
| 20 | } |
||||||
| 21 | |||||||
| 22 | /** |
||||||
| 23 | * Register helpers. |
||||||
| 24 | * |
||||||
| 25 | * @return void |
||||||
| 26 | */ |
||||||
| 27 | public function registerHelpers() |
||||||
| 28 | { |
||||||
| 29 | $helpers = glob($this->packagePath('/Helpers/*.php')); |
||||||
| 30 | foreach ($helpers as $helper) { |
||||||
| 31 | if (file_exists($helper)) { |
||||||
| 32 | require_once $helper; |
||||||
| 33 | } |
||||||
| 34 | } |
||||||
| 35 | } |
||||||
| 36 | |||||||
| 37 | /** |
||||||
| 38 | * @param $path |
||||||
| 39 | * |
||||||
| 40 | * @return string |
||||||
| 41 | */ |
||||||
| 42 | private function packagePath($path) |
||||||
| 43 | { |
||||||
| 44 | return __DIR__."/$path"; |
||||||
| 45 | } |
||||||
| 46 | |||||||
| 47 | /** |
||||||
| 48 | * Bootstrap services. |
||||||
| 49 | * |
||||||
| 50 | * @return void |
||||||
| 51 | */ |
||||||
| 52 | public function boot() |
||||||
| 53 | { |
||||||
| 54 | // load command files |
||||||
| 55 | $this->registerCommands(); |
||||||
| 56 | |||||||
| 57 | // load publisher files |
||||||
| 58 | $this->registerResources(); |
||||||
| 59 | } |
||||||
| 60 | |||||||
| 61 | /** |
||||||
| 62 | * Register commands. |
||||||
| 63 | * |
||||||
| 64 | * @return void |
||||||
| 65 | */ |
||||||
| 66 | private function registerCommands() |
||||||
| 67 | { |
||||||
| 68 | $this->commands(Commands\ClearCommand::class); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 69 | $this->commands(Commands\CacheCommand::class); |
||||||
| 70 | } |
||||||
| 71 | |||||||
| 72 | /** |
||||||
| 73 | * Register resources. |
||||||
| 74 | * |
||||||
| 75 | * @return void |
||||||
| 76 | */ |
||||||
| 77 | public function registerResources() |
||||||
| 78 | { |
||||||
| 79 | if ($this->isLumen() === false and function_exists('config_path')) { |
||||||
| 80 | // function not available and 'publish' not relevant in Lumen |
||||||
| 81 | |||||||
| 82 | $this->publishes( |
||||||
|
0 ignored issues
–
show
The method
publishes() does not exist on Hayrullah\Helpers\HelperServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 83 | [ |
||||||
| 84 | $this->packagePath($this->HELPERS_PATH.'helper.php') => app_path('Helpers/vendor/hyr-helpers.php'), |
||||||
| 85 | ], |
||||||
| 86 | 'hyr-helpers' |
||||||
| 87 | ); |
||||||
| 88 | } |
||||||
| 89 | } |
||||||
| 90 | |||||||
| 91 | /** |
||||||
| 92 | * Check if package is running under Lumen app. |
||||||
| 93 | * |
||||||
| 94 | * @return bool |
||||||
| 95 | */ |
||||||
| 96 | protected function isLumen() |
||||||
| 97 | { |
||||||
| 98 | return Str::contains($this->app->version(), 'Lumen') === true; |
||||||
| 99 | } |
||||||
| 100 | } |
||||||
| 101 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.