Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
10
17abstract class Base
18{
19 private $splittingChar = ' ';
20 private $filteredValue = '';
21
22 protected $filters = array();
23 protected $name = '';
24
25
26 function __construct($splittingChar = '')
27 {
28 $this->setSplittingChar($splittingChar);
29 }
30
45 public function process($value)
46 {
47 $this->initializeFilters();
48 $this->setFilteredValue('');
49 $found = false;
50
51 $str2 = '';
52 $strX = $value;
53 while ($str2 != $strX)
54 {
55 $str2 = $strX;
56 $strX = preg_replace($this->filters['search'], $this->filters['replace'], $str2);
57 }
58
59 if ($str2 != $value)
60 {
61 $this->setFilteredValue($str2);
62 $found = true;
63 }
64 return $found;
65 }
66
67
74 public function getFilteredValue()
75 {
76 return $this->filteredValue;
77 }
78
79
85 public function getName()
86 {
87 return $this->name;
88 }
89
90
94 protected function setFilteredValue($string)
95 {
96 $this->filteredValue = $string;
97 }
98
99
103 protected function setSplittingChar($char)
104 {
105 if (is_string($char) && $char != '')
106 {
107 $this->splittingChar = $char;
108 }
109 }
110
115 protected function getSplittingChar($customChar = '')
116 {
117 if (is_string($customChar) && $customChar != '')
118 {
119 return $customChar;
120 }
121 elseif (is_string($this->splittingChar) && $this->splittingChar != '')
122 {
123 return $this->splittingChar;
124 }
125 else
126 {
127 return ' ';
128 }
129 }
130
137 protected function getSplittingString($splitItemsCount = 2, $customSplitChar = '')
138 {
139 $glue = self::getSplittingChar($customSplitChar).'\\';
140 $result = '\\';
141 $result .= join($glue, range(1, $splitItemsCount));
142 return $result;
143 }
144
145 protected function initializeFilters()
146 {
147 if (!$this->filters)
148 {
149 $this->filters = $this->getFilters();
150 }
151 }
152
156 abstract protected function getFilters();
157
158}
getSplittingChar($customChar='')
Definition base.php:115
getSplittingString($splitItemsCount=2, $customSplitChar='')
Definition base.php:137
__construct($splittingChar='')
Definition base.php:26