Completed
Push — master ( 3fdc21...2574b5 )
by ReliQ
01:51
created

InvalidDirectory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forDirectory() 0 8 1
A getDirectory() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliqArts\Docweaver\Exceptions;
6
7
use ReliqArts\Docweaver\Contracts\Exception as ExceptionContract;
8
9
class InvalidDirectory extends Exception
10
{
11
    private const CODE = 4002;
12
13
    /**
14
     * @var null|string
15
     */
16
    protected $directory;
17
18
    /**
19
     * @param string            $directory Directory
20
     * @param ExceptionContract $previous  Previous Exception if nested exception
0 ignored issues
show
Documentation introduced by
Should the type for parameter $previous not be null|ExceptionContract?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
21
     *
22
     * @return ExceptionContract
23
     */
24
    public static function forDirectory(string $directory, ExceptionContract $previous = null): ExceptionContract
25
    {
26
        $message = sprintf('Invalid directory: `%s`.', $directory);
27
        $self = new self($message, self::CODE, $previous);
28
        $self->directory = $directory;
29
30
        return $self;
31
    }
32
33
    /**
34
     * @return null|string
35
     */
36
    final public function getDirectory(): ?string
37
    {
38
        return $this->directory;
39
    }
40
}
41