Passed
Push — master ( 9bbfd7...37d9a3 )
by Peter
02:54 queued 11s
created
AnalyzerText/Filter/Informative.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -24,48 +24,48 @@
 block discarded – undo
24 24
  */
25 25
 class Informative extends Filter
26 26
 {
27
-    /**
28
-     * Список фильтров.
29
-     *
30
-     * @var array
31
-     */
32
-    private $filters = array();
27
+	/**
28
+	 * Список фильтров.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	private $filters = array();
33 33
 
34
-    /**
35
-     * @param Text $iterator Текст
36
-     */
37
-    public function __construct(Text $iterator)
38
-    {
39
-        parent::__construct($iterator);
40
-        $this->filters = array(
41
-            new Interjection($this->getInnerIterator()),
42
-            new Particle($this->getInnerIterator()),
43
-            new Preposition($this->getInnerIterator()),
44
-            new Pronoun($this->getInnerIterator()),
45
-            new Union($this->getInnerIterator()),
46
-            new Adverb($this->getInnerIterator()),
47
-        );
48
-    }
34
+	/**
35
+	 * @param Text $iterator Текст
36
+	 */
37
+	public function __construct(Text $iterator)
38
+	{
39
+		parent::__construct($iterator);
40
+		$this->filters = array(
41
+			new Interjection($this->getInnerIterator()),
42
+			new Particle($this->getInnerIterator()),
43
+			new Preposition($this->getInnerIterator()),
44
+			new Pronoun($this->getInnerIterator()),
45
+			new Union($this->getInnerIterator()),
46
+			new Adverb($this->getInnerIterator()),
47
+		);
48
+	}
49 49
 
50
-    /**
51
-     * @see \FilterIterator::accept()
52
-     */
53
-    public function accept()
54
-    {
55
-        $word = $this->current();
56
-        // сначала ищем последовательности
57
-        foreach ($this->filters as $filter) {
58
-            if ($filter->isSequence($word)) {
59
-                return false;
60
-            }
61
-        }
62
-        // ищем простые и сложные формы
63
-        foreach ($this->filters as $filter) {
64
-            if ($filter->isSimple($word) || $filter->isComposite($word)) {
65
-                return false;
66
-            }
67
-        }
50
+	/**
51
+	 * @see \FilterIterator::accept()
52
+	 */
53
+	public function accept()
54
+	{
55
+		$word = $this->current();
56
+		// сначала ищем последовательности
57
+		foreach ($this->filters as $filter) {
58
+			if ($filter->isSequence($word)) {
59
+				return false;
60
+			}
61
+		}
62
+		// ищем простые и сложные формы
63
+		foreach ($this->filters as $filter) {
64
+			if ($filter->isSimple($word) || $filter->isComposite($word)) {
65
+				return false;
66
+			}
67
+		}
68 68
 
69
-        return true;
70
-    }
69
+		return true;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
AnalyzerText/Filter/Factory.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,87 +20,87 @@
 block discarded – undo
20 20
  */
21 21
 class Factory
22 22
 {
23
-    /**
24
-     * @var Analyzer
25
-     */
26
-    private $analyzer;
23
+	/**
24
+	 * @var Analyzer
25
+	 */
26
+	private $analyzer;
27 27
 
28
-    /**
29
-     * @param Analyzer $analyzer
30
-     */
31
-    public function __construct(Analyzer $analyzer)
32
-    {
33
-        $this->analyzer = $analyzer;
34
-    }
28
+	/**
29
+	 * @param Analyzer $analyzer
30
+	 */
31
+	public function __construct(Analyzer $analyzer)
32
+	{
33
+		$this->analyzer = $analyzer;
34
+	}
35 35
 
36
-    /**
37
-     * Применяет фильтр Informative.
38
-     *
39
-     * @return Factory
40
-     */
41
-    public function Informative()
42
-    {
43
-        return $this->apply(new Informative($this->analyzer->getText()));
44
-    }
36
+	/**
37
+	 * Применяет фильтр Informative.
38
+	 *
39
+	 * @return Factory
40
+	 */
41
+	public function Informative()
42
+	{
43
+		return $this->apply(new Informative($this->analyzer->getText()));
44
+	}
45 45
 
46
-    /**
47
-     * Применяет фильтр Preposition.
48
-     *
49
-     * @return Factory
50
-     */
51
-    public function Preposition()
52
-    {
53
-        return $this->apply(new Preposition($this->analyzer->getText()));
54
-    }
46
+	/**
47
+	 * Применяет фильтр Preposition.
48
+	 *
49
+	 * @return Factory
50
+	 */
51
+	public function Preposition()
52
+	{
53
+		return $this->apply(new Preposition($this->analyzer->getText()));
54
+	}
55 55
 
56
-    /**
57
-     * Применяет фильтр Pronoun.
58
-     *
59
-     * @return Factory
60
-     */
61
-    public function Pronoun()
62
-    {
63
-        return $this->apply(new Pronoun($this->analyzer->getText()));
64
-    }
56
+	/**
57
+	 * Применяет фильтр Pronoun.
58
+	 *
59
+	 * @return Factory
60
+	 */
61
+	public function Pronoun()
62
+	{
63
+		return $this->apply(new Pronoun($this->analyzer->getText()));
64
+	}
65 65
 
66
-    /**
67
-     * Применяет фильтр Union.
68
-     *
69
-     * @return Factory
70
-     */
71
-    public function Union()
72
-    {
73
-        return $this->apply(new Union($this->analyzer->getText()));
74
-    }
66
+	/**
67
+	 * Применяет фильтр Union.
68
+	 *
69
+	 * @return Factory
70
+	 */
71
+	public function Union()
72
+	{
73
+		return $this->apply(new Union($this->analyzer->getText()));
74
+	}
75 75
 
76
-    /**
77
-     * Применяет фильтр Adverb.
78
-     *
79
-     * @return Factory
80
-     */
81
-    public function Adverb()
82
-    {
83
-        return $this->apply(new Adverb($this->analyzer->getText()));
84
-    }
76
+	/**
77
+	 * Применяет фильтр Adverb.
78
+	 *
79
+	 * @return Factory
80
+	 */
81
+	public function Adverb()
82
+	{
83
+		return $this->apply(new Adverb($this->analyzer->getText()));
84
+	}
85 85
 
86
-    /**
87
-     * Применяет фильтр
88
-     *
89
-     * @param Filter $filter
90
-     *
91
-     * @return Factory
92
-     */
93
-    private function apply(Filter $filter)
94
-    {
95
-        if ($filter->getText()->count()) {
96
-            $words = array();
97
-            foreach ($filter as $word) {
98
-                $words[] = $word->getWord();
99
-            }
100
-            $text_class = get_class($filter->getText());
101
-            $this->analyzer->setText(new $text_class(implode(' ', $words)));
102
-        }
86
+	/**
87
+	 * Применяет фильтр
88
+	 *
89
+	 * @param Filter $filter
90
+	 *
91
+	 * @return Factory
92
+	 */
93
+	private function apply(Filter $filter)
94
+	{
95
+		if ($filter->getText()->count()) {
96
+			$words = array();
97
+			foreach ($filter as $word) {
98
+				$words[] = $word->getWord();
99
+			}
100
+			$text_class = get_class($filter->getText());
101
+			$this->analyzer->setText(new $text_class(implode(' ', $words)));
102
+		}
103 103
 
104
-        return $this;
105
-    }
104
+		return $this;
105
+	}
106 106
 }
Please login to merge, or discard this patch.
AnalyzerText/Analyzer/Analyzer.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -17,55 +17,55 @@
 block discarded – undo
17 17
  */
18 18
 abstract class Analyzer
19 19
 {
20
-    /**
21
-     * @var Text
22
-     */
23
-    protected $text;
20
+	/**
21
+	 * @var Text
22
+	 */
23
+	protected $text;
24 24
 
25
-    /**
26
-     * Устанавливает аналезируемый текст
27
-     *
28
-     * @param Text $text
29
-     *
30
-     * @return Analyzer
31
-     */
32
-    public function setText(Text $text)
33
-    {
34
-        $this->clear();
35
-        $this->text = $text;
25
+	/**
26
+	 * Устанавливает аналезируемый текст
27
+	 *
28
+	 * @param Text $text
29
+	 *
30
+	 * @return Analyzer
31
+	 */
32
+	public function setText(Text $text)
33
+	{
34
+		$this->clear();
35
+		$this->text = $text;
36 36
 
37
-        return $this;
38
-    }
37
+		return $this;
38
+	}
39 39
 
40
-    /**
41
-     * Возвращает список слов.
42
-     *
43
-     * @return Text
44
-     */
45
-    public function getText()
46
-    {
47
-        return $this->text;
48
-    }
40
+	/**
41
+	 * Возвращает список слов.
42
+	 *
43
+	 * @return Text
44
+	 */
45
+	public function getText()
46
+	{
47
+		return $this->text;
48
+	}
49 49
 
50
-    /**
51
-     * Очищает анализатор
52
-     *
53
-     * @return Analyzer
54
-     */
55
-    public function clear()
56
-    {
57
-        $this->text = null;
50
+	/**
51
+	 * Очищает анализатор
52
+	 *
53
+	 * @return Analyzer
54
+	 */
55
+	public function clear()
56
+	{
57
+		$this->text = null;
58 58
 
59
-        return $this;
60
-    }
59
+		return $this;
60
+	}
61 61
 
62
-    /**
63
-     * Возвращает фабрику фильтров для применения их.
64
-     *
65
-     * @return Factory
66
-     */
67
-    public function applyFilters()
68
-    {
69
-        return new Factory($this);
70
-    }
62
+	/**
63
+	 * Возвращает фабрику фильтров для применения их.
64
+	 *
65
+	 * @return Factory
66
+	 */
67
+	public function applyFilters()
68
+	{
69
+		return new Factory($this);
70
+	}
71 71
 }
Please login to merge, or discard this patch.
AnalyzerText/Text.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -18,75 +18,75 @@
 block discarded – undo
18 18
  */
19 19
 class Text extends \ArrayIterator
20 20
 {
21
-    /**
22
-     * Спиок всех слов в тексте в простой форме.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $plains = array();
21
+	/**
22
+	 * Спиок всех слов в тексте в простой форме.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $plains = array();
27 27
 
28
-    /**
29
-     * @param string $text
30
-     */
31
-    public function __construct($text)
32
-    {
33
-        $words = array();
34
-        // слово не может начинаться с тире и не может содержать только его
35
-        if (preg_match_all('/[[:alnum:]]+(?:[-\'][[:alnum:]]+)*/u', trim(strip_tags($text)), $match)) {
36
-            $words = $match[0];
37
-            // получение списка слов в нижнем регистре
38
-            $this->plains = explode(' ', mb_strtolower(implode(' ', $words), 'utf8'));
39
-        }
40
-        parent::__construct($words);
41
-    }
28
+	/**
29
+	 * @param string $text
30
+	 */
31
+	public function __construct($text)
32
+	{
33
+		$words = array();
34
+		// слово не может начинаться с тире и не может содержать только его
35
+		if (preg_match_all('/[[:alnum:]]+(?:[-\'][[:alnum:]]+)*/u', trim(strip_tags($text)), $match)) {
36
+			$words = $match[0];
37
+			// получение списка слов в нижнем регистре
38
+			$this->plains = explode(' ', mb_strtolower(implode(' ', $words), 'utf8'));
39
+		}
40
+		parent::__construct($words);
41
+	}
42 42
 
43
-    /**
44
-     * Возвращает список слов.
45
-     *
46
-     * @return array
47
-     */
48
-    public function getWords()
49
-    {
50
-        return $this->getArrayCopy();
51
-    }
43
+	/**
44
+	 * Возвращает список слов.
45
+	 *
46
+	 * @return array
47
+	 */
48
+	public function getWords()
49
+	{
50
+		return $this->getArrayCopy();
51
+	}
52 52
 
53
-    /**
54
-     * Возвращает текущий элемент
55
-     *
56
-     * @return Word
57
-     */
58
-    public function current()
59
-    {
60
-        return new Word(parent::current(), $this->plains[$this->key()]);
61
-    }
53
+	/**
54
+	 * Возвращает текущий элемент
55
+	 *
56
+	 * @return Word
57
+	 */
58
+	public function current()
59
+	{
60
+		return new Word(parent::current(), $this->plains[$this->key()]);
61
+	}
62 62
 
63
-    /**
64
-     * Удаляет слово из текста.
65
-     */
66
-    public function remove()
67
-    {
68
-        $this->offsetUnset($this->key());
69
-        unset($this->plains[$this->key()]);
70
-    }
63
+	/**
64
+	 * Удаляет слово из текста.
65
+	 */
66
+	public function remove()
67
+	{
68
+		$this->offsetUnset($this->key());
69
+		unset($this->plains[$this->key()]);
70
+	}
71 71
 
72
-    /**
73
-     * Заменяет слово в тексте.
74
-     *
75
-     * @param Word $word
76
-     */
77
-    public function replace(Word $word)
78
-    {
79
-        $this->offsetSet($this->key(), $word->getWord());
80
-        $this->plains[$this->key()] = $word->getPlain();
81
-    }
72
+	/**
73
+	 * Заменяет слово в тексте.
74
+	 *
75
+	 * @param Word $word
76
+	 */
77
+	public function replace(Word $word)
78
+	{
79
+		$this->offsetSet($this->key(), $word->getWord());
80
+		$this->plains[$this->key()] = $word->getPlain();
81
+	}
82 82
 
83
-    /**
84
-     * Возвращает текст
85
-     *
86
-     * @return string
87
-     */
88
-    public function __toString()
89
-    {
90
-        return implode(' ', $this->getWords());
91
-    }
83
+	/**
84
+	 * Возвращает текст
85
+	 *
86
+	 * @return string
87
+	 */
88
+	public function __toString()
89
+	{
90
+		return implode(' ', $this->getWords());
91
+	}
92 92
 }
Please login to merge, or discard this patch.