Completed
Branch BUG-11137-domain-base (06ea45)
by
unknown
44:54 queued 34:30
created

DomainBase::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain;
4
5
use DomainException;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit('No direct access allowed');
8
9
10
/**
11
 * DomainBase Class
12
 * A container for all domain data related to the plugin
13
 *
14
 * @package EventEspresso\core\domain
15
 * @author  Darren Ethier
16
 * @since   4.9.38
17
 */
18
abstract class DomainBase
19
{
20
21
    /**
22
     * Equivalent to `__FILE__` for main plugin file.
23
     *
24
     * @var string
25
     */
26
    private $plugin_file;
27
28
    /**
29
     * String indicating version for plugin
30
     *
31
     * @var string
32
     */
33
    private $version;
34
35
    /**
36
     * @var string $plugin_basename
37
     */
38
    private $plugin_basename;
39
40
    /**
41
     * @var string $plugin_path
42
     */
43
    private $plugin_path;
44
45
    /**
46
     * @var string $plugin_url
47
     */
48
    private $plugin_url;
49
50
51
52
    /**
53
     * Initializes internal properties.
54
     *
55
     * @param string $plugin_file
56
     * @param string $version
57
     */
58
    public function __construct($plugin_file, $version)
59
    {
60
        $this->plugin_file = $plugin_file;
61
        $this->version = $version;
62
        $this->plugin_basename = plugin_basename($plugin_file);
63
        $this->plugin_path = plugin_dir_path($plugin_file);
64
        $this->plugin_url = plugin_dir_url($plugin_file);
65
    }
66
67
68
69
    /**
70
     * @return string
71
     * @throws DomainException
72
     */
73
    public function pluginFile()
74
    {
75
        return $this->plugin_file;
76
    }
77
78
79
80
    /**
81
     * @return string
82
     * @throws DomainException
83
     */
84
    public function pluginBasename()
85
    {
86
        return $this->plugin_basename;
87
    }
88
89
90
91
    /**
92
     * @return string
93
     */
94
    public function pluginPath()
95
    {
96
        return $this->plugin_path;
97
    }
98
99
100
101
    /**
102
     * @return string
103
     * @throws DomainException
104
     */
105
    public function pluginUrl()
106
    {
107
        return $this->plugin_url;
108
    }
109
110
111
112
    /**
113
     * @return string
114
     * @throws DomainException
115
     */
116
    public function version()
117
    {
118
        return $this->version;
119
    }
120
121
122
}
123