Filesystem   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Storage
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Storage;
16
17
use Phossa2\Shared\Base\ObjectAbstract;
18
use Phossa2\Storage\Driver\LocalDriver;
19
use Phossa2\Storage\Traits\DriverAwareTrait;
20
use Phossa2\Storage\Interfaces\DriverInterface;
21
use Phossa2\Storage\Traits\PermissionAwareTrait;
22
use Phossa2\Storage\Interfaces\FilesystemInterface;
23
use Phossa2\Storage\Interfaces\PermissionAwareInterface;
24
25
/**
26
 * Filesystem
27
 *
28
 * Implementation of FilesystemInterface. A wrapper of driver with permissions
29
 *
30
 * @package Phossa2\Storage
31
 * @author  Hong Zhang <[email protected]>
32
 * @see     ObjectAbstract
33
 * @see     FilesystemInterface
34
 * @version 2.1.0
35
 * @since   2.0.0 added
36
 * @since   2.1.0 modified `__construct` to accept string as first param
37
 */
38
class Filesystem extends ObjectAbstract implements FilesystemInterface
39
{
40
    use PermissionAwareTrait, DriverAwareTrait;
41
42
    /**
43
     * Set the driver and its global permissions
44
     *
45
     * @param  DriverInterface|string $driverOrPath driver or local path
46
     * @param  int $permissions filesystem permissions
47
     * @access public
48
     * @since  2.1.0 changed first param
49
     * @api
50
     */
51
    public function __construct(
52
        $driverOrPath,
53
        /*# int */ $permissions = PermissionAwareInterface::PERM_ALL
54
    ) {
55
        // path provided, init a LocalDriver
56
        if (is_string($driverOrPath)) {
57
            $driverOrPath = new LocalDriver($driverOrPath);
58
        }
59
60
        // set underlying driver
61
        $this->setDriver($driverOrPath);
62
63
        // set permissions for THIS filesystem
64
        $this->setPermissions($permissions);
65
    }
66
}
67