Completed
Branch add-test-cases (10aafb)
by Basenko
05:32
created

MakeEchoServerConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 58
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B handle() 0 38 1
1
<?php
2
3
namespace MadWeb\Initializer\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Container\Container;
7
use Illuminate\Foundation\Bus\Dispatchable;
8
9
class MakeEchoServerConfig
10
{
11
    use Dispatchable, Queueable;
12
13
    /**
14
     * Config for overriding default echo server values.
15
     */
16
    protected $config;
17
18 6
    public function __construct(array $config = [])
19
    {
20 6
        $this->config = $config;
21 6
    }
22
23
    /**
24
     * Execute the job.
25
     *
26
     * @return string
27
     */
28 6
    public function handle(Container $container)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30 6
        $path = base_path('laravel-echo-server.json');
31 6
        file_put_contents(
32 6
            $path,
33 6
            json_encode(array_replace_recursive([
34 6
                'authHost' => url('/'),
35 6
                'authEndpoint' => '/broadcasting/auth',
36 6
                'database' => 'redis',
37
                'databaseConfig' => [
38
                    'redis' => [
39 6
                        'host' => config('database.redis.default.host'),
40 6
                        'port' => config('database.redis.default.port'),
41
                    ],
42
                    'sqlite' => [
43
                        'databasePath' => '/storage/laravel-echo-server.sqlite',
44
                    ],
45
                ],
46 6
                'devMode' => config('app.debug'),
47 6
                'host' => parse_url(url('/'), PHP_URL_HOST),
48 6
                'port' => 6001,
49 6
                'protocol' => 'http',
50
                'socketio' => [],
51 6
                'sslCertPath' => '',
52 6
                'sslKeyPath' => '',
53 6
                'sslCertChainPath' => '',
54 6
                'sslPassphrase' => '',
55
                'apiOriginAllow' => [
56
                    'allowCors' => false,
57
                    'allowOrigin' => '',
58
                    'allowMethods' => '',
59
                    'allowHeaders' => ''
60
                ]
61 6
            ], $this->config), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
62
        );
63
64 6
        return 'Config file for web-socket server created. File: '.$path;
65
    }
66
}
67