Completed
Push — stable ( 428d33...707315 )
by Nuno
07:37 queued 04:39
created

Application::runningInConsole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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\Foundation\PackageManifest;
15
use Illuminate\Events\EventServiceProvider;
16
use LaravelZero\Framework\Exceptions\ConsoleException;
17
use Illuminate\Foundation\Application as BaseApplication;
18
use Symfony\Component\Console\Exception\CommandNotFoundException;
19
20
/**
21
 * This is the Laravel Zero Framework Application implementation.
22
 */
23
class Application extends BaseApplication
24
{
25
    /**
26
     * Get the builds path.
27
     *
28
     * @param  string $path Optionally, a path to append to the base path
29
     *
30
     * @return string
31
     */
32 1
    public function buildsPath(string $path = ''): string
33
    {
34 1
        return $this->basePath('builds'.($path ? DIRECTORY_SEPARATOR.$path : $path));
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 19
    protected function registerBaseBindings()
41
    {
42 19
        parent::registerBaseBindings();
43
44
        /**
45
         * Ignores auto-discovery.
46
         */
47 19
        $this->make(PackageManifest::class)->manifest = [];
48 19
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 19
    protected function registerBaseServiceProviders()
54
    {
55 19
        $this->register(new EventServiceProvider($this));
56 19
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 19
    public function version()
62
    {
63 19
        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...
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 1
    public function runningInConsole()
70
    {
71 1
        return true;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 1
    public function isDownForMaintenance()
78
    {
79 1
        return false;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function configurationIsCached()
86
    {
87
        return false;
88
    }
89
90
    /**
91
     * Throw an Console Exception with the given data unless the given condition is true.
92
     *
93
     * @param  int $code
94
     * @param  string $message
95
     * @param  array $headers
96
     * @return void
97
     *
98
     * @throws \Symfony\Component\Console\Exception\CommandNotFoundException
99
     * @throws \LaravelZero\Framework\Contracts\Exceptions\ConsoleException
100
     */
101 1
    public function abort($code, $message = '', array $headers = [])
102
    {
103 1
        if ($code == 404) {
104 1
            throw new CommandNotFoundException($message);
105
        }
106
107 1
        throw new ConsoleException($code, $message, $headers);
108
    }
109
}
110