| Total Complexity | 6 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | trait QuotesTrait |
||
| 26 | { |
||
| 27 | |||
| 28 | /** |
||
|
1 ignored issue
–
show
|
|||
| 29 | * @var bool |
||
| 30 | */ |
||
| 31 | private $quotes = false; |
||
| 32 | |||
| 33 | 85 | public function initQuotesAttributes(SimpleXMLElement $node) |
|
| 34 | { |
||
| 35 | 85 | if (isset($node['quotes']) && "true" === (string) $node['quotes']) { |
|
| 36 | 24 | $this->quotes = true; |
|
| 37 | } |
||
| 38 | 85 | } |
|
| 39 | |||
| 40 | /** |
||
|
1 ignored issue
–
show
|
|||
| 41 | * @param string $text |
||
|
2 ignored issues
–
show
|
|||
| 42 | * @return string |
||
|
1 ignored issue
–
show
|
|||
| 43 | */ |
||
| 44 | 69 | public function addSurroundingQuotes($text) |
|
| 45 | { |
||
| 46 | 69 | if ($this->quotes) { |
|
| 47 | 4 | $openQuote = CiteProc::getContext()->getLocale()->filter("terms", "open-quote")->single; |
|
| 48 | 4 | $closeQuote = CiteProc::getContext()->getLocale()->filter("terms", "close-quote")->single; |
|
| 49 | 4 | $text = $this->replaceOuterQuotes($text, $openQuote, $closeQuote); |
|
| 50 | 4 | return $openQuote . $text . $closeQuote; |
|
| 51 | } |
||
| 52 | 69 | return $text; |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
|
1 ignored issue
–
show
|
|||
| 56 | * @param $text |
||
|
1 ignored issue
–
show
|
|||
| 57 | * @param $outerOpenQuote |
||
|
1 ignored issue
–
show
|
|||
| 58 | * @param $outerCloseQuote |
||
|
1 ignored issue
–
show
|
|||
| 59 | * @return string |
||
|
1 ignored issue
–
show
|
|||
| 60 | */ |
||
| 61 | 4 | private function replaceOuterQuotes($text, $outerOpenQuote, $outerCloseQuote) |
|
| 70 | } |
||
| 71 | } |
||
| 72 |