Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| Segment | |
0.00% |
0 / 13 |
|
0.00% |
0 / 10 |
110 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| addContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getStartOffset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setStartOffset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getEndOffset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setEndOffset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHash | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setHash | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Wikispeech\Segment; |
| 4 | |
| 5 | /** |
| 6 | * @file |
| 7 | * @ingroup Extensions |
| 8 | * @license GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @since 0.1.13 Change `$content` to array of `SegmentContent` |
| 13 | * @since 0.1.10 |
| 14 | */ |
| 15 | class Segment { |
| 16 | |
| 17 | /** @var SegmentContent[] */ |
| 18 | private $content; |
| 19 | |
| 20 | /** |
| 21 | * The offset of the first character of the segment, within the text node it appears. |
| 22 | * Used to determine start of a segment in the original HTML. |
| 23 | * @var int|null |
| 24 | */ |
| 25 | private $startOffset; |
| 26 | |
| 27 | /** |
| 28 | * The offset of the last character of the segment within the text node it appears. |
| 29 | * Used to determine end of a segment in the original HTML. |
| 30 | * @var int|null |
| 31 | */ |
| 32 | private $endOffset; |
| 33 | |
| 34 | /** @var string|null */ |
| 35 | private $hash; |
| 36 | |
| 37 | /** |
| 38 | * @since 0.1.13 Change `$content` to array of `SegmentContent` |
| 39 | * @since 0.1.10 |
| 40 | * @param SegmentContent[] $content |
| 41 | * @param int|null $startOffset |
| 42 | * @param int|null $endOffset |
| 43 | * @param string|null $hash |
| 44 | */ |
| 45 | public function __construct( |
| 46 | array $content = [], |
| 47 | ?int $startOffset = null, |
| 48 | ?int $endOffset = null, |
| 49 | ?string $hash = null |
| 50 | ) { |
| 51 | $this->content = $content; |
| 52 | $this->startOffset = $startOffset; |
| 53 | $this->endOffset = $endOffset; |
| 54 | $this->hash = $hash; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @since 0.1.13 Change return value to array of `SegmentContent` |
| 59 | * @since 0.1.10 |
| 60 | * @return SegmentContent[] |
| 61 | */ |
| 62 | public function getContent(): array { |
| 63 | return $this->content; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @since 0.1.13 Change `$content` to array of `SegmentContent` |
| 68 | * @since 0.1.10 |
| 69 | * @param SegmentContent[] $content |
| 70 | */ |
| 71 | public function setContent( array $content ): void { |
| 72 | $this->content = $content; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @since 0.1.13 Change `$content` to `SegmentContent` |
| 77 | * @since 0.1.10 |
| 78 | * @param SegmentContent $content |
| 79 | */ |
| 80 | public function addContent( SegmentContent $content ): void { |
| 81 | $this->content[] = $content; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @since 0.1.10 |
| 86 | * @return int|null |
| 87 | */ |
| 88 | public function getStartOffset(): ?int { |
| 89 | return $this->startOffset; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @since 0.1.10 |
| 94 | * @param int|null $startOffset |
| 95 | */ |
| 96 | public function setStartOffset( ?int $startOffset ): void { |
| 97 | $this->startOffset = $startOffset; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @since 0.1.10 |
| 102 | * @return int|null |
| 103 | */ |
| 104 | public function getEndOffset(): ?int { |
| 105 | return $this->endOffset; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @since 0.1.10 |
| 110 | * @param int|null $endOffset |
| 111 | */ |
| 112 | public function setEndOffset( ?int $endOffset ): void { |
| 113 | $this->endOffset = $endOffset; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @since 0.1.10 |
| 118 | * @return string|null |
| 119 | */ |
| 120 | public function getHash(): ?string { |
| 121 | return $this->hash; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @since 0.1.10 |
| 126 | * @param string|null $hash |
| 127 | */ |
| 128 | public function setHash( ?string $hash ): void { |
| 129 | $this->hash = $hash; |
| 130 | } |
| 131 | |
| 132 | } |