Passed
Push — master ( 17602b...453007 )
by Chris
04:37
created

Plain   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 19
c 0
b 0
f 0
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Chris
5
 * Date: 4/12/2014
6
 * Time: 12:04 PM
7
 */
8
namespace Seufert\Hamle\Text;
9
10
use Seufert\Hamle\Text;
11
12
class Plain extends Text {
13
  protected $s;
14
  protected $type;
15
16
  function __construct($s, $type = self::TOKEN_HTML) {
17
    $this->s = str_replace('\\$', "$", $s);
18
    $this->type = $type;
19
  }
20
21
  function toPHP() {
22
    return Text::varToCode($this->s);
23
  }
24
25
  function toHTML($escape = false) {
26
    if ($this->type == self::TOKEN_CODE)
27
      return $this->s;
28
    return htmlspecialchars($this->s);
29
  }
30
}