Completed
Branch TASK/11208/update-bundled-gate... (60edbd)
by
unknown
12:10
created

FilePath   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A __toString() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\domain\values;
4
5
use EventEspresso\core\exceptions\InvalidDataTypeException;
6
use EventEspresso\core\exceptions\InvalidFilePathException;
7
8
defined('EVENT_ESPRESSO_VERSION') || exit;
9
10
11
12
/**
13
 * Class FilePath
14
 * Value Object representing a valid readable filepath
15
 *
16
 * @package EventEspresso\core\domain\values
17
 * @author  Brent Christensen
18
 * @since   4.9.51
19
 */
20
class FilePath
21
{
22
23
    /**
24
     * @var string file_path
25
     */
26
    private $file_path;
27
28
29
    /**
30
     * FilePath constructor.
31
     *
32
     * @param string $file_path
33
     * @throws InvalidDataTypeException
34
     * @throws InvalidFilePathException
35
     */
36
    public function __construct($file_path)
37
    {
38
        if (! is_string($file_path)) {
39
            throw new InvalidDataTypeException(
40
                '$file_path',
41
                $file_path,
42
                'string'
43
            );
44
        }
45
        if (! is_readable($file_path)) {
46
            throw new InvalidFilePathException($file_path);
47
        }
48
        $this->file_path = $file_path;
49
    }
50
51
52
    /**
53
     * @return string
54
     */
55
    public function __toString()
56
    {
57
        return $this->file_path;
58
    }
59
60
61
}
62