Completed
Push — master ( 092870...dbc3bd )
by Mahmoud
04:24
created

PortButler::getContainersApiRoutes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace App\Port\Butler\Portals;
4
5
use App\Port\Butler\Exceptions\WrongConfigurationsException;
6
use Illuminate\Support\Facades\Config;
7
use Illuminate\Support\Facades\File;
8
9
/**
10
 * Class PortButler.
11
 *
12
 * NOTE: You can access this Class functions with the facade [ModuleConfig].
13
 *
14
 * @author Mahmoud Zalt <[email protected]>
15
 */
16
class PortButler
17
{
18
19
    /**
20
     * Get the containers namespace value from the containers config file
21
     *
22
     * @return  string
23
     */
24
    public function getContainersNamespace()
25
    {
26
        return Config::get('hello.containers.namespace');
27
    }
28
29
    /**
30
     * Get the containers names
31
     *
32
     * @return  array
33
     */
34
    public function getContainersNames()
35
    {
36
        $containersNames = [];
37
38
        foreach($this->getContainersPaths() as $containersPath){
39
            $containersNames[] = basename($containersPath);
40
        }
41
42
        return $containersNames;
43
    }
44
45
    /**
46
     * get containers directories paths
47
     *
48
     * @return  mixed
49
     */
50
    public function getContainersPaths()
51
    {
52
        return File::directories(app_path('Containers'));
53
    }
54
55
    /**
56
     * build the main service provider class namespace
57
     *
58
     * @param $containersNamespace
59
     * @param $containerName
60
     *
61
     * @return  string
62
     */
63
    public function buildMainServiceProvider($containersNamespace, $containerName)
64
    {
65
        if($containerName != 'Port') {
66
            return $containersNamespace . "\\Containers\\" . $containerName . "\\Settings\\Providers\\" . $containerName . "ServiceProvider";
67
        }
68
69
        return "App" . "\\Port" . "\\Provider\\Providers\\" . $containerName . "ServiceProvider";
70
    }
71
72
    /**
73
     * @return  mixed
74
     */
75
    public function getLoginWebPageName()
76
    {
77
        $loginPage = Config::get('hello.containers.login-page-name');
78
79
        if (is_null($loginPage)) {
80
            throw new WrongConfigurationsException();
81
        }
82
83
        return $loginPage;
84
    }
85
86
}
87