Completed
Push — master ( 974531...773161 )
by Asif
02:14
created

Shortcode::strip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Webwizo\Shortcodes;
2
3
use Webwizo\Shortcodes\Compilers\ShortcodeCompiler;
4
5
class Shortcode
6
{
7
    /**
8
     * Shortcode compiler
9
     * @var \Webwizo\Shortcodes\Compilers\ShortcodeCompiler
10
     */
11
    protected $compiler;
12
13
    /**
14
     * Constructor
15
     *
16
     * @param \Webwizo\Shortcodes\Compilers\ShortcodeCompiler $compiler
17
     */
18
    public function __construct(ShortcodeCompiler $compiler)
19
    {
20
        $this->compiler = $compiler;
21
    }
22
23
    /**
24
     * Register a new shortcode
25
     * @param  string $name
26
     * @param  callable|string $callback
27
     * @return \Webwizo\Shortcodes\Shortcode
28
     */
29
    public function register($name, $callback)
30
    {
31
        $this->compiler->add($name, $callback);
32
        return $this;
33
    }
34
35
    /**
36
     * Enable the laravel-shortcodes
37
     * @return \Webwizo\Shortcodes\Shortcode
38
     */
39
    public function enable()
40
    {
41
        $this->compiler->enable();
42
        return $this;
43
    }
44
45
    /**
46
     * Disable the laravel-shortcodes
47
     * @return \Webwizo\Shortcodes\Shortcode
48
     */
49
    public function disable()
50
    {
51
        $this->compiler->disable();
52
        return $this;
53
    }
54
55
    /**
56
     * Compile the given string
57
     * @param  string $value
58
     * @return string
59
     */
60
    public function compile($value)
61
    {
62
        // Always enable when we call the compile method directly
63
        $this->enable();
64
65
        // return compiled contents
66
        return $this->compiler->compile($value);
67
    }
68
69
    public function strip($value)
70
    {
71
        return $this->compiler->strip($value);
72
    }
73
}
74