| Conditions | 10 |
| Paths | 12 |
| Total Lines | 86 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 27 | public function register() |
||
| 28 | { |
||
| 29 | $config = require __DIR__.'/../config/wamp.php'; |
||
| 30 | $file = base_path('config/wamp.php'); |
||
| 31 | if (class_exists('\Laravel\Lumen\Application')) { |
||
| 32 | // Configure wamp config for lumen |
||
| 33 | app()->configure('wamp'); |
||
| 34 | $config = config('wamp') ?? $config; |
||
| 35 | } else { |
||
| 36 | if (file_exists($file)) { |
||
| 37 | // Get laravel config for WAMP |
||
| 38 | $config = require $file; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /* |
||
| 43 | * Register facade alias |
||
| 44 | */ |
||
| 45 | $this->app->alias('wamp', '\sonrac\WAMP\Facades\WAMP'); |
||
| 46 | |||
| 47 | /* |
||
| 48 | * Register console command |
||
| 49 | */ |
||
| 50 | $this->app->singleton('wamp.run', '\sonrac\WAMP\Commands\RunServer'); |
||
| 51 | |||
| 52 | $this->app->singleton('wampClient', function () use ($config) { |
||
| 53 | return new Client($config['realm']); |
||
| 54 | }); |
||
| 55 | |||
| 56 | /* |
||
| 57 | * Register routers |
||
| 58 | */ |
||
| 59 | foreach ([ |
||
| 60 | 'rpcRouter' => [ |
||
| 61 | 'sonrac\WAMP\Contracts\RPCRouterInterface', |
||
| 62 | 'sonrac\WAMP\Routers\RPCRouter', |
||
| 63 | ], |
||
| 64 | 'pubSubRouter' => [ |
||
| 65 | 'sonrac\WAMP\Contracts\PubSubRouterInterface', |
||
| 66 | 'sonrac\WAMP\Routers\PubSubRouter', |
||
| 67 | ], |
||
| 68 | 'wampRouter' => [ |
||
| 69 | 'sonrac\WAMP\Contracts\WAMPRouterInterface', |
||
| 70 | 'sonrac\WAMP\Routers\Router', |
||
| 71 | ], |
||
| 72 | ] as $alias => $abstract) { |
||
| 73 | $this->app->singleton($abstract[0], $abstract[1]); |
||
| 74 | $this->app->alias($abstract[0], $alias); |
||
| 75 | } |
||
| 76 | |||
| 77 | $this->app->singleton('sonrac\WAMP\Contracts\ClientTransportServiceProvider', function () use ($config) { |
||
| 78 | return new RawSocketClientTransportProvider($config['host'], $config['port']); |
||
| 79 | }); |
||
| 80 | |||
| 81 | /* |
||
| 82 | * Register loggers |
||
| 83 | */ |
||
| 84 | $this->app->singleton('wamp.server.logger', function () use ($config) { |
||
| 85 | $fileName = isset($config['log_file_server']) && $config['log_file_server'] ? $config['log_file_server'] : 'wamp-server.log'; |
||
| 86 | $path = storage_path('logs/'.$fileName); |
||
| 87 | |||
| 88 | $handler = (new StreamHandler($path, MonologLogger::DEBUG)) |
||
| 89 | ->setFormatter(new LineFormatter(null, null, true, true)); |
||
| 90 | |||
| 91 | return new MonologLogger($fileName, [$handler]); |
||
| 92 | }); |
||
| 93 | |||
| 94 | $this->app->singleton('wamp.client.logger', function () use ($config) { |
||
| 95 | $fileName = isset($config['log_file_client']) && $config['log_file_client'] ? $config['log_file_client'] : 'wamp-client.log'; |
||
| 96 | $path = storage_path('logs/'.$fileName); |
||
| 97 | |||
| 98 | $handler = (new StreamHandler($path, MonologLogger::DEBUG)) |
||
| 99 | ->setFormatter(new LineFormatter(null, null, true, true)); |
||
| 100 | |||
| 101 | return new MonologLogger($fileName, [$handler]); |
||
| 102 | }); |
||
| 103 | /* |
||
| 104 | * Set logging |
||
| 105 | */ |
||
| 106 | if (isset($config['pathLogFile']) && null !== $config['pathLogFile']) { |
||
| 107 | $handler = (new StreamHandler($config['pathLogFile'], MonologLogger::DEBUG)) |
||
| 108 | ->setFormatter(new LineFormatter(null, null, true, true)); |
||
| 109 | |||
| 110 | $logger = new MonologLogger('wamp-client', [$handler]); |
||
| 111 | |||
| 112 | Logger::set($logger); |
||
| 113 | } |
||
| 116 |
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