Passed
Push — 0.8.x ( dbd8e8...e4bd6c )
by Alexander
06:37 queued 03:14
created

FilesystemManager::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php 
2
3
/**
4
 * Lenevor Framework
5
 *
6
 * LICENSE
7
 *
8
 * This source file is subject to the new BSD license that is bundled
9
 * with this package in the file license.md.
10
 * It is also available through the world-wide-web at this URL:
11
 * https://lenevor.com/license
12
 * If you did not receive a copy of the license and are unable to
13
 * obtain it through the world-wide-web, please send an email
14
 * to [email protected] so we can send you a copy immediately.
15
 *
16
 * @package     Lenevor
17
 * @subpackage  Base
18
 * @link        https://lenevor.com
19
 * @copyright   Copyright (c) 2019 - 2023 Alexander Campo <[email protected]>
20
 * @license     https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md
21
 */
22
23
namespace Syscodes\Components\Filesystem;
24
25
/**
26
 * Allows manage the distint adapters of file system.
27
 */
28
class FilesystemManager
29
{
30
    /**
31
     * The application instance.
32
     * 
33
     * @var \Syscodes\Components\Contracts\Core\Application $app
34
     */
35
    protected $app;
36
    
37
    /**
38
     * The array of resolved filesystem drivers.
39
     * 
40
     * @var array $disks
41
     */
42
    protected $disks = [];
43
44
    /**
45
     * Constructor. Create a new FilesystemManager instance.
46
     * 
47
     * @param  \Syscodes\Components\Contracts\Core\Application  $app
48
     * 
49
     * @return void
50
     */
51
    public function __construct($app)
52
    {
53
        $this->app = $app;
54
    }
55
56
    /**
57
     * Get a filesystem instance.
58
     *
59
     * @param  string|null  $name
60
     * @return \Illuminate\Contracts\Filesystem\Filesystem
0 ignored issues
show
Bug introduced by
The type Illuminate\Contracts\Filesystem\Filesystem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
61
     */
62
    public function disk($name = null)
63
    {
64
        $name = $name ?: $this->getDefaultDriver();
65
66
        return $this->disks[$name] = $this->get($name);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->disks[$name] = $this->get($name) returns the type Syscodes\Components\Cont...s\Filesystem\Filesystem which is incompatible with the documented return type Illuminate\Contracts\Filesystem\Filesystem.
Loading history...
67
    }
68
    
69
    /**
70
     * Attempt to get the disk from the local cache.
71
     * 
72
     * @param  string  $name
73
     * 
74
     * @return \Syscodes\Components\Contracts\Filesystem\Filesystem
75
     */
76
    protected function get($name)
77
    {
78
        return $this->disks[$name] ?? $this->resolve($name);
0 ignored issues
show
Bug introduced by
The method resolve() does not exist on Syscodes\Components\Filesystem\FilesystemManager. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

78
        return $this->disks[$name] ?? $this->/** @scrutinizer ignore-call */ resolve($name);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
    }
80
    
81
    /**
82
     * Get the default driver name.
83
     * 
84
     * @return string
85
     */
86
    public function getDefaultDriver(): string
87
    {
88
        return $this->app['config']['filesystems.default'];
89
    }
90
}