Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function setTelephone($telephone) |
||
30 | { |
||
31 | /** |
||
32 | * Hack to support leading + sign |
||
33 | * @see \luya\cms\models\NavItemPageBlockItem::rules() |
||
34 | * @link https://github.com/luyadev/luya/pull/1815 |
||
35 | */ |
||
36 | $telephone = ltrim($telephone, '\\'); |
||
37 | |||
38 | $validator = new RegularExpressionValidator([ |
||
39 | 'pattern' => '#^(?:0|\+[0-9]{2})[\d- ]+$#' |
||
40 | ]); |
||
41 | if ($validator->validate($telephone, $error)) { |
||
42 | $this->_telephone = $telephone; |
||
43 | } |
||
44 | } |
||
45 | |||
72 |