-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathReplacedShortcode.php
More file actions
59 lines (51 loc) · 1.4 KB
/
ReplacedShortcode.php
File metadata and controls
59 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Thunder\Shortcode\Shortcode;
/**
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class ReplacedShortcode extends AbstractShortcode
{
/** @var string */
private $replacement;
/** @var string */
private $text;
/** @var int */
private $offset;
/** @param string $replacement */
public function __construct(ParsedShortcodeInterface $shortcode, $replacement)
{
$this->name = $shortcode->getName();
$this->parameters = $shortcode->getParameters();
$this->content = $shortcode->getContent();
$this->bbCode = $shortcode->getBbCode();
$this->text = $shortcode->getText();
$this->offset = $shortcode->getOffset();
$this->replacement = $replacement;
}
/**
* @param string $replacement
*
* @return self
*/
public function withReplacement($replacement)
{
$base = new Shortcode($this->name, $this->parameters, $this->content, $this->bbCode);
$parsed = new ParsedShortcode($base, $this->text, $this->offset);
return new self($parsed, $replacement);
}
/** @return string */
public function getReplacement()
{
return $this->replacement;
}
/** @return string */
public function getText()
{
return $this->text;
}
/** @return int */
public function getOffset()
{
return $this->offset;
}
}