OptAlign   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 69
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A oaquote_extra() 0 7 1
1
<?php
2
namespace EMT\Tret;
3
4
class OptAlign extends AbstractTret
5
{
6
7
    public $classes = array(
8
        'oa_obracket_sp_s' => "margin-right:0.3em;",
9
        "oa_obracket_sp_b" => "margin-left:-0.3em;",
10
        "oa_obracket_nl_b" => "margin-left:-0.3em;",
11
        "oa_comma_b" => "margin-right:-0.2em;",
12
        "oa_comma_e" => "margin-left:0.2em;",
13
        'oa_oquote_nl' => "margin-left:-0.44em;",
14
        'oa_oqoute_sp_s' => "margin-right:0.44em;",
15
        'oa_oqoute_sp_q' => "margin-left:-0.44em;",
16
    );
17
18
    /**
19
     * Базовые параметры тофа
20
     *
21
     * @var array
22
     */
23
    public $title = "Оптическое выравнивание";
24
    public $rules = array(
25
        'oa_oquote' => array(
26
            'description' => 'Оптическое выравнивание открывающей кавычки',
27
            //'disabled'      => true,
28
            'pattern' => array(
29
                '/([a-zа-яё\-]{3,})(\040|\&nbsp\;|\t)(\&laquo\;)/uie',
30
                '/(\n|\r|^)(\&laquo\;)/ei'
31
            ),
32
            'replacement' => array(
33
                '$m[1] . $this->tag($m[2], "span", array("class"=>"oa_oqoute_sp_s")) . $this->tag($m[3], "span", array("class"=>"oa_oqoute_sp_q"))',
34
                '$m[1] . $this->tag($m[2], "span", array("class"=>"oa_oquote_nl"))',
35
            ),
36
        ),
37
        'oa_oquote_extra' => array(
38
            'description' => 'Оптическое выравнивание кавычки',
39
            //'disabled'      => true,
40
            'function' => 'oaquote_extra'
41
        ),
42
        'oa_obracket_coma' => array(
43
            'description' => 'Оптическое выравнивание для пунктуации (скобка и запятая)',
44
            //'disabled'      => true,
45
            'pattern' => array(
46
                '/(\040|\&nbsp\;|\t)\(/ei',
47
                '/(\n|\r|^)\(/ei',
48
                '/([а-яёa-z0-9]+)\,(\040+)/iue',
49
            ),
50
            'replacement' => array(
51
                '$this->tag($m[1], "span", array("class"=>"oa_obracket_sp_s")) . $this->tag("(", "span", array("class"=>"oa_obracket_sp_b"))',
52
                '$m[1] . $this->tag("(", "span", array("class"=>"oa_obracket_nl_b"))',
53
                '$m[1] . $this->tag(",", "span", array("class"=>"oa_comma_b")) . $this->tag(" ", "span", array("class"=>"oa_comma_e"))',
54
            ),
55
        ),
56
57
    );
58
59
    /**
60
     * Если стоит открывающая кавычка после <p> надо делать её висячей
61
     *
62
     * @return void
63
     */
64
    protected function oaquote_extra()
65
    {
66
        $this->_text = $this->preg_replace_e(
67
            '/(<' . self::BASE64_PARAGRAPH_TAG . '>)([\040\t]+)?(\&laquo\;)/e',
68
            '$m[1] . $this->tag($m[3], "span", array("class"=>"oa_oquote_nl"))',
69
            $this->_text);
70
    }
71
72
}
73