Completed
Pull Request — master (#5)
by Mark
14:49
created

Shortcode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __get() 0 10 3
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