1 | <?php |
||||||||
2 | |||||||||
3 | declare(strict_types=1); |
||||||||
4 | |||||||||
5 | /* |
||||||||
6 | * This file is part of the EasyWeChatComposer. |
||||||||
7 | * |
||||||||
8 | * (c) 张铭阳 <[email protected]> |
||||||||
9 | * |
||||||||
10 | * This source file is subject to the MIT license that is bundled |
||||||||
11 | * with this source code in the file LICENSE. |
||||||||
12 | */ |
||||||||
13 | |||||||||
14 | namespace EasyWeChatComposer\Laravel; |
||||||||
15 | |||||||||
16 | use EasyWeChatComposer\EasyWeChat; |
||||||||
17 | use EasyWeChatComposer\Encryption\DefaultEncrypter; |
||||||||
18 | use Illuminate\Foundation\Application; |
||||||||
0 ignored issues
–
show
|
|||||||||
19 | use Illuminate\Support\Arr; |
||||||||
0 ignored issues
–
show
The type
Illuminate\Support\Arr was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
20 | use Illuminate\Support\Facades\Cache; |
||||||||
0 ignored issues
–
show
The type
Illuminate\Support\Facades\Cache was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
21 | use Illuminate\Support\Facades\Route; |
||||||||
0 ignored issues
–
show
The type
Illuminate\Support\Facades\Route was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
22 | use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
||||||||
0 ignored issues
–
show
The type
Illuminate\Support\ServiceProvider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
23 | use RuntimeException; |
||||||||
24 | |||||||||
25 | class ServiceProvider extends LaravelServiceProvider |
||||||||
26 | { |
||||||||
27 | /** |
||||||||
28 | * Bootstrap any application services. |
||||||||
29 | */ |
||||||||
30 | public function boot() |
||||||||
31 | { |
||||||||
32 | $this->registerRoutes(); |
||||||||
33 | $this->publishes([ |
||||||||
34 | __DIR__.'/config.php' => config_path('easywechat-composer.php'), |
||||||||
0 ignored issues
–
show
The function
config_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
35 | ]); |
||||||||
36 | |||||||||
37 | EasyWeChat::setEncryptionKey( |
||||||||
38 | $defaultKey = $this->getKey() |
||||||||
39 | ); |
||||||||
40 | |||||||||
41 | EasyWeChat::withDelegation() |
||||||||
42 | ->toHost($this->config('delegation.host')) |
||||||||
43 | ->ability($this->config('delegation.enabled')); |
||||||||
44 | |||||||||
45 | $this->app->when(DefaultEncrypter::class)->needs('$key')->give($defaultKey); |
||||||||
46 | } |
||||||||
47 | |||||||||
48 | /** |
||||||||
49 | * Register routes. |
||||||||
50 | */ |
||||||||
51 | protected function registerRoutes() |
||||||||
52 | { |
||||||||
53 | Route::prefix('easywechat-composer')->namespace('EasyWeChatComposer\Laravel\Http\Controllers')->group(function () { |
||||||||
54 | $this->loadRoutesFrom(__DIR__.'/routes.php'); |
||||||||
55 | }); |
||||||||
56 | } |
||||||||
57 | |||||||||
58 | /** |
||||||||
59 | * Register any application services. |
||||||||
60 | */ |
||||||||
61 | public function register() |
||||||||
62 | { |
||||||||
63 | $this->configure(); |
||||||||
64 | } |
||||||||
65 | |||||||||
66 | /** |
||||||||
67 | * Register config. |
||||||||
68 | */ |
||||||||
69 | protected function configure() |
||||||||
70 | { |
||||||||
71 | $this->mergeConfigFrom( |
||||||||
72 | __DIR__.'/config.php', 'easywechat-composer' |
||||||||
73 | ); |
||||||||
74 | } |
||||||||
75 | |||||||||
76 | /** |
||||||||
77 | * Get the specified configuration value. |
||||||||
78 | * |
||||||||
79 | * @param string|null $key |
||||||||
80 | * @param mixed $default |
||||||||
81 | * |
||||||||
82 | * @return mixed |
||||||||
83 | */ |
||||||||
84 | protected function config($key = null, $default = null) |
||||||||
85 | { |
||||||||
86 | $config = $this->app['config']->get('easywechat-composer'); |
||||||||
87 | |||||||||
88 | if (is_null($key)) { |
||||||||
89 | return $config; |
||||||||
90 | } |
||||||||
91 | |||||||||
92 | return Arr::get($config, $key, $default); |
||||||||
93 | } |
||||||||
94 | |||||||||
95 | /** |
||||||||
96 | * @return string |
||||||||
97 | */ |
||||||||
98 | protected function getKey() |
||||||||
99 | { |
||||||||
100 | return $this->config('encryption.key') ?: $this->getMd5Key(); |
||||||||
101 | } |
||||||||
102 | |||||||||
103 | /** |
||||||||
104 | * @return string |
||||||||
105 | */ |
||||||||
106 | protected function getMd5Key() |
||||||||
107 | { |
||||||||
108 | $ttl = (version_compare(Application::VERSION, '5.8') === -1) ? 30 : 1800; |
||||||||
109 | |||||||||
110 | return Cache::remember('easywechat-composer.encryption_key', $ttl, function () { |
||||||||
111 | throw_unless(file_exists($path = base_path('composer.lock')), RuntimeException::class, 'No encryption key provided.'); |
||||||||
0 ignored issues
–
show
The function
throw_unless was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
base_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
112 | |||||||||
113 | return md5_file($path); |
||||||||
114 | }); |
||||||||
115 | } |
||||||||
116 | } |
||||||||
117 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths