Completed
Push — master ( 1a8c72...81e1ab )
by Marco
12:55
created

PathTrait::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace Comodojo\Zip\Traits;
2
3
use \Comodojo\Zip\Interfaces\ZipInterface;
4
use \Comodojo\Exception\ZipException;
5
6
/**
7
 * Path helper trait.
8
 *
9
 * @package     Comodojo Zip
10
 * @author      Marco Giovinazzi <[email protected]>
11
 * @license     MIT
12
 *
13
 * LICENSE:
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 */
23
24
trait PathTrait {
25
26
    /**
27
     * Current base path
28
     *
29
     * @var string
30
     */
31
    private $path;
32
33
    /**
34
     * Set current base path (to add relative files to zip archive)
35
     *
36
     * @param string|null $path
37
     *
38
     * @return Zip
0 ignored issues
show
Bug introduced by
The type Comodojo\Zip\Traits\Zip 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...
39
     * @throws ZipException
40
     */
41
    public function setPath(?string $path = null): ZipInterface {
42
43
        if ( $path === null ) {
44
            $this->path = null;
45
        } else if ( !file_exists($path) ) {
46
            throw new ZipException("Not existent path: $path");
47
        } else {
48
            $this->path = $path;
49
        }
50
51
        return $this;
52
53
    }
54
55
    /**
56
     * Get current base path
57
     *
58
     * @return string|null
59
     */
60
    public function getPath(): ?string {
61
62
        return $this->path;
63
64
    }
65
66
}
67