Completed
Push — master ( 120efa...e232e3 )
by Mark
06:50
created

Shortcode::__get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
namespace Jaybizzle\Shortcodes;
4
5
use Jaybizzle\Shortcodes\ShortcodeContract;
6
7
abstract class Shortcode implements ShortcodeContract
8
{
9
    /**
10
     * The shortcode attributes.
11
     *
12
     * @var array
13
     */
14
    public $attributes;
15
16
    /**
17
     * The content of the shortcode.
18
     *
19
     * @var string
20
     */
21
    public $content;
22
23
    /**
24
     * The shortcode tag.
25
     *
26
     * @var string
27
     */
28
    public static $shortcode;
29
30
    public function __construct($attributes, $content)
31
    {
32
        $this->content = $content;
33
        $this->attributes = $attributes;
34
    }
35
36
    public function __get($name)
37
    {
38
        if ($name == 'shortcode') {
39
            return static::$shortcode;
40
        } elseif (isset($this->attributes[$name])) {
41
            return $this->attributes[$name];
42
        }
43
44
        throw new \Exception("Unknown property '{$name}'.");
45
    }
46
}
47