Passed
Push — stable ( e66a33...6fec69 )
by Nuno
02:21
created

Application   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 4
dl 0
loc 74
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A buildsPath() 0 4 2
A registerBaseServiceProviders() 0 4 1
A version() 0 4 1
A runningInConsole() 0 4 1
A isDownForMaintenance() 0 4 1
A configurationIsCached() 0 4 1
A abort() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[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 LaravelZero\Framework;
13
14
use Illuminate\Events\EventServiceProvider;
15
use LaravelZero\Framework\Exceptions\ConsoleException;
16
use Illuminate\Foundation\Application as BaseApplication;
17
use Symfony\Component\Console\Exception\CommandNotFoundException;
18
19
/**
20
 * This is the Laravel Zero Framework Application implementation.
21
 */
22
class Application extends BaseApplication
23
{
24
    /**
25
     * Get the builds path.
26
     *
27
     * @param  string $path Optionally, a path to append to the base path
28
     *
29
     * @return string
30
     */
31 1
    public function buildsPath(string $path = ''): string
32
    {
33 1
        return $this->basePath('builds'.($path ? DIRECTORY_SEPARATOR.$path : $path));
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 21
    protected function registerBaseServiceProviders()
40
    {
41 21
        $this->register(new EventServiceProvider($this));
42 21
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 21
    public function version()
48
    {
49 21
        return $this->app['config']->get('app.version');
0 ignored issues
show
Documentation introduced by
The property app does not exist on object<LaravelZero\Framework\Application>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function runningInConsole()
56
    {
57 1
        return true;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function isDownForMaintenance()
64
    {
65 1
        return false;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function configurationIsCached()
72
    {
73
        return false;
74
    }
75
76
    /**
77
     * Throw an Console Exception with the given data unless the given condition is true.
78
     *
79
     * @param  int $code
80
     * @param  string $message
81
     * @param  array $headers
82
     * @return void
83
     *
84
     * @throws \Symfony\Component\Console\Exception\CommandNotFoundException
85
     * @throws \LaravelZero\Framework\Contracts\Exceptions\ConsoleException
86
     */
87 1
    public function abort($code, $message = '', array $headers = [])
88
    {
89 1
        if ($code == 404) {
90 1
            throw new CommandNotFoundException($message);
91
        }
92
93 1
        throw new ConsoleException($code, $message, $headers);
94
    }
95
}
96