Completed
Push — master ( 1b73c5...b9dd45 )
by Mahmoud
03:37
created

ViewsLoaderTrait::runViewsAutoLoader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace App\Port\View\Loaders;
4
5
use App;
6
use App\Port\Butler\Portals\Facade\PortButler;
7
use DB;
8
use File;
9
use Illuminate\Support\Facades\View;
10
use Log;
11
12
/**
13
 * Class ViewsLoaderTrait.
14
 *
15
 * @author  Mahmoud Zalt <[email protected]>
16
 */
17
trait ViewsLoaderTrait
18
{
19
20
    protected $portViewsDirectories = [
21
22
    ];
23
24
    public function runViewsAutoLoader()
25
    {
26
        $this->loadViewsFromPort();
0 ignored issues
show
Unused Code introduced by
The call to the method App\Port\View\Loaders\Vi...it::loadViewsFromPort() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
27
        $this->loadViewsFromContainers();
28
    }
29
30 View Code Duplication
    private function loadViewsFromContainers()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        foreach (PortButler::getContainersNames() as $containerName) {
33
34
            $containerViewDirectory = base_path('app/Containers/' . $containerName . '/UI/WEB/Views/');
35
36
            if (File::isDirectory($containerViewDirectory)) {
37
                $this->loadViews($containerViewDirectory);
38
            }
39
        }
40
    }
41
42
    private function loadViewsFromPort()
43
    {
44
45
    }
46
47
    private function loadViews($directory)
48
    {
49
        View::addLocation($directory);
50
    }
51
}
52