ViewPublisher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSource() 0 15 3
1
<?php
2
3
/*
4
 * This file is part of Laravel Service Provider.
5
 *
6
 * (c) DraperStudio <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DraperStudio\ServiceProvider\Publisher;
13
14
use InvalidArgumentException;
15
16
class ViewPublisher extends Publisher
17
{
18
    /**
19
     * Get the source views directory to publish.
20
     *
21
     * @param string $packagePath
22
     *
23
     * @return string
24
     *
25
     * @throws \InvalidArgumentException
26
     */
27
    protected function getSource($packagePath)
28
    {
29
        $sources = [
30
            "{$packagePath}/resources/views",
31
            "{$packagePath}/views",
32
        ];
33
34
        foreach ($sources as $source) {
35
            if ($this->files->isDirectory($source)) {
36
                return [$source => $this->publishPath.'/'.$this->packageName];
0 ignored issues
show
Bug introduced by
The property packageName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
            }
38
        }
39
40
        throw new InvalidArgumentException('Views not found.');
41
    }
42
}
43