Completed
Push — master ( 396c8f...1fcaad )
by WEBEWEB
02:16
created

AbstractAssetManager::setDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 E
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 WBW\Bundle\BootstrapBundle\Manager\Asset;
13
14
use WBW\Bundle\BootstrapBundle\Helper\AssetHelper;
15
use WBW\Bundle\BootstrapBundle\Manager\AbstractManager;
16
use WBW\Bundle\BootstrapBundle\Manager\ManagerInterface;
17
use WBW\Library\Core\Exception\Argument\IllegalArgumentException;
18
use WBW\Library\Core\FileSystem\FileHelper;
19
20
/**
21
 * Abstract asset manager.
22
 *
23
 * @author e <https://github.com/e/>
24
 * @package WBW\Bundle\BootstrapBundle\Manager\Asset
25
 * @abstract
26
 */
27
abstract class AbstractAssetManager extends AbstractManager {
28
29
    /**
30
     * Directory.
31
     *
32
     * @var string
33
     */
34
    private $directory;
35
36
    /**
37
     * Extension.
38
     *
39
     * @var string
40
     */
41
    private $extension;
42
43
    /**
44
     * Constructor.
45
     *
46
     * @param string $directory The directory.
47
     * @param string $extension The extension.
48
     */
49
    public function __construct($directory, $extension) {
50
        parent::__construct();
51
        $this->setDirectory($directory);
52
        $this->setExtension($extension);
53
    }
54
55
    /**
56
     * Determines if the filename exists.
57
     *
58
     * @return boolean Returns true in case of success, false otherwise.
59
     */
60
    public function exists() {
61
        return file_exists($this->getFilename());
62
    }
63
64
    /**
65
     * Get the directory.
66
     *
67
     * @return string Returns the directory.
68
     */
69
    public function getDirectory() {
70
        return $this->directory;
71
    }
72
73
    /**
74
     * Get the extension.
75
     *
76
     * @return string Returns the extension.
77
     */
78
    public function getExtension() {
79
        return $this->extension;
80
    }
81
82
    /**
83
     * Get the filename.
84
     *
85
     * @return string Returns the filename.
86
     */
87
    public function getFilename() {
88
        return $this->getDirectory() . "/resources" . $this->getExtension();
89
    }
90
91
    /**
92
     * Set the directory.
93
     *
94
     * @param string $directory The directory.
95
     * @return ManagerInterface Returns this resources manager.
96
     */
97
    protected function setDirectory($directory) {
98
        $this->directory = $directory;
99
        return $this;
100
    }
101
102
    /**
103
     * Set the extension.
104
     *
105
     * @param string $extension The extension.
106
     * @return ManagerInterface Returns this resources manager.
107
     */
108
    protected function setExtension($extension) {
109
        $this->extension = $extension;
110
        return $this;
111
    }
112
113
}
114