EMTTretAbbr
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 0
lcom 0
cbo 1
dl 0
loc 127
c 0
b 0
f 0
1
<?php
2
3
/**
4
* Evgeny Muravjev Typograph, http://mdash.ru
5
* Version: 3.4 Gold Master
6
* Release Date: September 20, 2014
7
* Authors: Evgeny Muravjev & Alexander Drutsa  
8
*/
9
10
namespace Fenrizbes\TypographBundle\EMT;
11
12
/**
13
 * @see EMTTret
14
 */
15
16
class EMTTretAbbr extends EMTTret
17
{
18
	public $title = "Сокращения";
19
	
20
	public $domain_zones = array('ru','ру','com','ком','org','орг', 'уа', 'ua');
21
	
22
	public $classes = array(
23
			'nowrap'           => 'word-spacing:nowrap;',
24
			);
25
	
26
	public $rules = array(
27
		'nobr_abbreviation' => array(
28
				'description'	=> 'Расстановка пробелов перед сокращениями dpi, lpi',
29
				'pattern' 		=> '/(\s+|^|\>)(\d+)(\040|\t)*(dpi|lpi)([\s\;\.\?\!\:\(]|$)/i', 
30
				'replacement' 	=> '\1\2&nbsp;\4\5'
31
			),
32
		'nobr_acronym' => array(
33
				'description'	=> 'Расстановка пробелов перед сокращениями гл., стр., рис., илл., ст., п.',
34
				'pattern' 		=> '/(\s|^|\>|\()(гл|стр|рис|илл?|ст|п|с)\.(\040|\t)*(\d+)(\&nbsp\;|\s|\.|\,|\?|\!|$)/iu', 
35
				'replacement' 	=> '\1\2.&nbsp;\4\5'
36
			),		
37
		'nobr_sm_im' => array(
38
				'description'	=> 'Расстановка пробелов перед сокращениями см., им.',
39
				'pattern' 		=> '/(\s|^|\>|\()(см|им)\.(\040|\t)*([а-яё0-9a-z]+)(\s|\.|\,|\?|\!|$)/iu', 
40
				'replacement' 	=> '\1\2.&nbsp;\4\5'
41
			),	
42
		'nobr_locations' => array(
43
				'description'	=> 'Расстановка пробелов в сокращениях г., ул., пер., д.',
44
				'pattern' 		=> array(
45
						'/(\s|^|\>)(г|ул|пер|просп|пл|бул|наб|пр|ш|туп)\.(\040|\t)*([а-яё0-9a-z]+)(\s|\.|\,|\?|\!|$)/iu', 
46
						'/(\s|^|\>)(б\-р|пр\-кт)(\040|\t)*([а-яё0-9a-z]+)(\s|\.|\,|\?|\!|$)/iu', 
47
						'/(\s|^|\>)(д|кв|эт)\.(\040|\t)*(\d+)(\s|\.|\,|\?|\!|$)/iu', 
48
						),
49
				'replacement' 	=> array(
50
						'\1\2.&nbsp;\4\5',
51
						'\1\2&nbsp;\4\5',
52
						'\1\2.&nbsp;\4\5',
53
						)
54
			),		
55
		'nbsp_before_unit' => array(
56
				'description'	=> 'Замена символов и привязка сокращений в размерных величинах: м, см, м2…',
57
				'pattern' 		=> array(
58
							'/(\s|^|\>|\&nbsp\;|\,)(\d+)( |\&nbsp\;)?(м|мм|см|дм|км|гм|km|dm|cm|mm)(\s|\.|\!|\?|\,|$|\&plusmn\;|\;)/iu', 
59
							'/(\s|^|\>|\&nbsp\;|\,)(\d+)( |\&nbsp\;)?(м|мм|см|дм|км|гм|km|dm|cm|mm)([32]|&sup3;|&sup2;)(\s|\.|\!|\?|\,|$|\&plusmn\;|\;)/iue'
60
							),
61
				'replacement' 	=> array(
62
							'\1\2&nbsp;\4\5',
63
							'$m[1].$m[2]."&nbsp;".$m[4].($m[5]=="3"||$m[5]=="2"? "&sup".$m[5].";" : $m[5] ).$m[6]'
64
							),
65
			),
66
		'nbsp_before_weight_unit' => array(
67
				'description'	=> 'Замена символов и привязка сокращений в весовых величинах: г, кг, мг…',
68
				'pattern' 		=> '/(\s|^|\>|\&nbsp\;|\,)(\d+)( |\&nbsp\;)?(г|кг|мг|т)(\s|\.|\!|\?|\,|$|\&nbsp\;|\;)/iu', 
69
				'replacement' 	=> '\1\2&nbsp;\4\5',
70
			),						
71
		'nobr_before_unit_volt' => array(
72
				'description'	=> 'Установка пробельных символов в сокращении вольт',
73
				'pattern' 		=> '/(\d+)([вВ]| В)(\s|\.|\!|\?|\,|$)/u', 
74
				'replacement' 	=> '\1&nbsp;В\3'
75
			),				
76
		'ps_pps' => array(
77
				'description'	=> 'Объединение сокращений P.S., P.P.S.',
78
				'pattern' 		=> '/(^|\040|\t|\>|\r|\n)(p\.\040?)(p\.\040?)?(s\.)([^\<])/ie',
79
				'replacement' 	=> '$m[1] . $this->tag(trim($m[2]) . " " . ($m[3] ? trim($m[3]) . " " : ""). $m[4], "span",  array("class" => "nowrap") ).$m[5] '
80
			),	
81
		'nobr_vtch_itd_itp'     => array(
82
				'description'	=> 'Объединение сокращений и т.д., и т.п., в т.ч.',			
83
				'cycled'		=> true,
84
				'pattern' 		=> array(
85
						'/(^|\s|\&nbsp\;)и( |\&nbsp\;)т\.?[ ]?д(\.|$|\s|\&nbsp\;)/ue',
86
						'/(^|\s|\&nbsp\;)и( |\&nbsp\;)т\.?[ ]?п(\.|$|\s|\&nbsp\;)/ue',
87
						'/(^|\s|\&nbsp\;)в( |\&nbsp\;)т\.?[ ]?ч(\.|$|\s|\&nbsp\;)/ue',						
88
					),
89
				'replacement' 	=> array(
90
						'$m[1].$this->tag("и т. д.", "span",  array("class" => "nowrap")).($m[3]!="."? $m[3] : "" )',
91
						'$m[1].$this->tag("и т. п.", "span",  array("class" => "nowrap")).($m[3]!="."? $m[3] : "" )',
92
						'$m[1].$this->tag("в т. ч.", "span",  array("class" => "nowrap")).($m[3]!="."? $m[3] : "" )',
93
					)
94
			),
95
		'nbsp_te'     => array(
96
				'description'	=> 'Обработка т.е.',			
97
				'pattern' 		=> '/(^|\s|\&nbsp\;)([тТ])\.?[ ]?е\./ue',
98
				'replacement' 	=> '$m[1].$this->tag($m[2].". е.", "span",  array("class" => "nowrap"))',
99
			),
100
		'nbsp_money_abbr' => array(
101
				'description'	=> 'Форматирование денежных сокращений (расстановка пробелов и привязка названия валюты к числу)',
102
				'pattern' 		=> '/(\d)((\040|\&nbsp\;)?(тыс|млн|млрд)\.?(\040|\&nbsp\;)?)?(\040|\&nbsp\;)?(руб\.|долл\.|евро|€|&euro;|\$|у[\.]? ?е[\.]?)/ieu', 
103
				'replacement' 	=> '$m[1].($m[4]?"&nbsp;".$m[4].($m[4]=="тыс"?".":""):"")."&nbsp;".(!preg_match("#у[\\\\.]? ?е[\\\\.]?#iu",$m[7])?$m[7]:"у.е.")',
104
			),
105
		'nbsp_org_abbr' => array(
106
				'description'	=> 'Привязка сокращений форм собственности к названиям организаций',
107
				'pattern' 		=> '/([^a-zA-Zа-яёА-ЯЁ]|^)(ООО|ЗАО|ОАО|НИИ|ПБОЮЛ) ([a-zA-Zа-яёА-ЯЁ]|\"|\&laquo\;|\&bdquo\;|<)/u', 
108
				'replacement' 	=> '\1\2&nbsp;\3'
109
			),
110
		'nobr_gost' => array(
111
				'description'	=> 'Привязка сокращения ГОСТ к номеру',
112
				'pattern' 		=> array(
113
						'/(\040|\t|\&nbsp\;|^)ГОСТ( |\&nbsp\;)?(\d+)((\-|\&minus\;|\&mdash\;)(\d+))?(( |\&nbsp\;)(\-|\&mdash\;))?/ieu',
114
						'/(\040|\t|\&nbsp\;|^|\>)ГОСТ( |\&nbsp\;)?(\d+)(\-|\&minus\;|\&mdash\;)(\d+)/ieu',
115
						),
116
				'replacement' 	=> array(
117
						'$m[1].$this->tag("ГОСТ ".$m[3].(isset($m[6])?"&ndash;".$m[6]:"").(isset($m[7])?" &mdash;":""),"span", array("class"=>"nowrap"))',
118
						'$m[1]."ГОСТ ".$m[3]."&ndash;".$m[5]',
119
						),
120
			),
121
			/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
122
		'nobr_vtch_itd_itp'     => array(
123
				'description'	=> 'Привязка сокращений до н.э., н.э.',
124
				'pattern' 		=> array(
125
				
126
				//IV в до н.э, в V-VIвв до нэ., третий в. н.э.
127
				
128
						'/(\s|\&nbsp\;)и( |\&nbsp\;)т\.?[ ]?д\./ue',
129
						'/(\s|\&nbsp\;)и( |\&nbsp\;)т\.?[ ]?п\./ue',
130
						'/(\s|\&nbsp\;)в( |\&nbsp\;)т\.?[ ]?ч\./ue',						
131
					),
132
				'replacement' 	=> array(
133
						'$m[1].$this->tag("и т. д.", "span",  array("class" => "nowrap"))',
134
						'$m[1].$this->tag("и т. п.", "span",  array("class" => "nowrap"))',
135
						'$m[1].$this->tag("в т. ч.", "span",  array("class" => "nowrap"))',
136
					)
137
			),
138
			*/
139
		
140
		
141
		);
142
}