Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
Section.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\PageTranslation;
5
12class Section {
14 private $open;
16 private $contents;
18 private $close;
19
20 public function __construct( string $open, string $contents, string $close ) {
21 $this->open = $open;
22 $this->contents = $contents;
23 $this->close = $close;
24 }
25
26 public function contents(): string {
27 // If <translate> tags are on their own line, avoid build-up of newlines
28 return preg_replace( '/\A\n|\n\z/', '', $this->contents );
29 }
30
31 public function wrappedContents(): string {
32 return $this->open . $this->contents . $this->close;
33 }
34}
Section is one pair of <translate>...</translate> tags.
Definition Section.php:12