Etc   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A remove_nbsp() 0 19 3
1
<?php
2
namespace EMT\Tret;
3
4
class Etc extends AbstractTret
5
{
6
7
    public $classes = array(
8
        'nowrap' => 'word-spacing:nowrap;',
9
    );
10
11
    /**
12
     * Базовые параметры тофа
13
     *
14
     * @var array
15
     */
16
    public $title = "Прочее";
17
    public $rules = array(
18
        'acute_accent' => array(
19
            'description' => 'Акцент',
20
            'pattern' => '/(у|е|ы|а|о|э|я|и|ю|ё)\`(\w)/i',
21
            'replacement' => '\1&#769;\2'
22
        ),
23
24
        'word_sup' => array(
25
            'description' => 'Надстрочный текст после символа ^',
26
            'pattern' => '/((\s|\&nbsp\;|^)+)\^([a-zа-яё0-9\.\:\,\-]+)(\s|\&nbsp\;|$|\.$)/ieu',
27
            'replacement' => '"" . $this->tag($this->tag($m[3],"small"),"sup") . $m[4]'
28
        ),
29
        'century_period' => array(
30
            'description' => 'Тире между диапозоном веков',
31
            'pattern' => '/(\040|\t|\&nbsp\;|^)([XIV]{1,5})(-|\&mdash\;)([XIV]{1,5})(( |\&nbsp\;)?(в\.в\.|вв\.|вв|в\.|в))/eu',
32
            'replacement' => '$m[1] .$this->tag($m[2]."&mdash;".$m[4]." вв.","span", array("class"=>"nowrap"))'
33
        ),
34
        'time_interval' => array(
35
            'description' => 'Тире и отмена переноса между диапозоном времени',
36
            'pattern' => '/([^\d\>]|^)([\d]{1,2}\:[\d]{2})(-|\&mdash\;|\&minus\;)([\d]{1,2}\:[\d]{2})([^\d\<]|$)/eui',
37
            'replacement' => '$m[1] . $this->tag($m[2]."&mdash;".$m[4],"span", array("class"=>"nowrap")).$m[5]'
38
        ),
39
        'expand_no_nbsp_in_nobr' => array(
40
            'description' => 'Удаление nbsp в nobr/nowrap тэгах',
41
            'function' => 'remove_nbsp'
42
        ),
43
    );
44
45
    protected function remove_nbsp()
46
    {
47
        $thetag = $this->tag("###", 'span', array('class' => "nowrap"));
48
        $arr = explode("###", $thetag);
49
        $b = preg_quote($arr[0], '/');
50
        $e = preg_quote($arr[1], '/');
51
52
        $match = '/(^|[^a-zа-яё])([a-zа-яё]+)\&nbsp\;(' . $b . ')/iu';
53
        do {
54
            $this->_text = preg_replace($match, '\1\3\2 ', $this->_text);
55
        } while (preg_match($match, $this->_text));
56
57
        $match = '/(' . $e . ')\&nbsp\;([a-zа-яё]+)($|[^a-zа-яё])/iu';
58
        do {
59
            $this->_text = preg_replace($match, ' \2\1\3', $this->_text);
60
        } while (preg_match($match, $this->_text));
61
62
        $this->_text = $this->preg_replace_e('/' . $b . '.*?' . $e . '/iue', 'str_replace("&nbsp;"," ",$m[0]);', $this->_text);
63
    }
64
65
}
66