EMTTretPunctmark
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 0
lcom 0
cbo 1
dl 0
loc 64
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 EMTTretPunctmark extends EMTTret
17
{
18
	public $title = "Пунктуация и знаки препинания";
19
	
20
	public $rules = array( 
21
	 	'auto_comma' => array(
22
	 			'description'	=> 'Расстановка запятых перед а, но',
23
		 		'pattern' 		=> '/([a-zа-яё])(\s|&nbsp;)(но|а)(\s|&nbsp;)/iu',
24
		 		'replacement' 	=> '\1,\2\3\4'
25
	 		), 
26
		'punctuation_marks_limit' => array(
27
				'description'	=> 'Лишние восклицательные, вопросительные знаки и точки',
28
				'pattern' 		=> '/([\!\.\?]){4,}/', 
29
				'replacement' 	=> '\1\1\1'
30
			), 	
31
		'punctuation_marks_base_limit' => array(
32
				'description'	=> 'Лишние запятые, двоеточия, точки с запятой',
33
				'pattern' 		=> '/([\,]|[\:]|[\;]]){2,}/',
34
				'replacement' 	=> '\1'
35
			),
36
		'hellip' => array(
37
				'description'	=> 'Замена трех точек на знак многоточия',
38
				'simple_replace'=> true,
39
				'pattern' 		=> '...',
40
				'replacement'   => '&hellip;'
41
			),		
42
		'fix_excl_quest_marks' => array(
43
				'description'	=> 'Замена восклицательного и вопросительного знаков местами',
44
				'pattern' 		=> '/([a-zа-яё0-9])\!\?(\s|$|\<)/ui',
45
				'replacement' 	=> '\1?!\2'
46
			),
47
		'fix_pmarks' => array(
48
				'description'	=> 'Замена сдвоенных знаков препинания на одинарные',
49
				'pattern' 		=> array(
50
							'/([^\!\?])\.\./',
51
							'/([a-zа-яё0-9])(\!|\.)(\!|\.|\?)(\s|$|\<)/ui', 
52
							'/([a-zа-яё0-9])(\?)(\?)(\s|$|\<)/ui',
53
							),
54
				'replacement' 	=> array(
55
							'\1.',
56
							'\1\2\4',
57
							'\1\2\4'
58
							),
59
			),
60
		'fix_brackets' => array(
61
				'description'	=> 'Лишние пробелы после открывающей скобочки и перед закрывающей',
62
				'pattern' 		=> array('/(\()(\040|\t)+/', '/(\040|\t)+(\))/'),
63
				'replacement' 	=> array('\1', '\2')
64
			),
65
		'fix_brackets_space' => array(
66
				'description'	=> 'Пробел перед открывающей скобочкой',
67
				'pattern' 		=> '/([a-zа-яё0-9])(\()/iu',
68
				'replacement' 	=> '\1 \2'
69
			),			
70
		'dot_on_end' => array(
71
				'description'	=> 'Точка в конце текста, если её там нет',
72
				'disabled'      => true,				
73
				'pattern' 		=> '/([a-zа-яё0-9])(\040|\t|\&nbsp\;)*$/ui',
74
				//'pattern' 		=> '/(([^\.\!\?])|(&(ra|ld)quo;))$/',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
75
				'replacement' 	=> '\1.'
76
			),
77
			
78
		);
79
}