Completed
Push — master ( ce020b...db331d )
by Peter
02:12
created

InlineWrapper::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/zamm
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 *
11
 */
12
13
namespace Maslosoft\Zamm\Helpers;
14
15
/**
16
 * Wrapper
17
 * @property Wrapper $md Get markdown wrapped code
18
 * @property Wrapper $html Get html `pre` wrapped code
19
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
20
 */
21 View Code Duplication
class InlineWrapper
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
24
	private $text = '';
25
	private $isMd = false;
26
	private $isHtml = false;
27
28
	public function __construct($text)
29
	{
30
		$this->text = $text;
31
	}
32
33
	public function __get($name)
34
	{
35
		return $this->$name();
36
	}
37
38
	public function md()
39
	{
40
		$this->isMd = true;
41
		return $this;
42
	}
43
44
	public function html()
45
	{
46
		$this->isHtml = true;
47
		return $this;
48
	}
49
50
	public function __toString()
51
	{
52
		if ($this->isMd)
53
		{
54
			return "`$this->text`";
55
		}
56
		if ($this->isHtml)
57
		{
58
			return "<code>$this->text</code>";
59
		}
60
		return $this->text;
61
	}
62
63
}
64