| Conditions | 2 |
| Paths | 2 |
| Total Lines | 9 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public function __construct($id, $pattern, $message = null) { |
||
| 38 | $this->pattern = '/^' . $pattern . '$/'; |
||
| 39 | $this->check = $this; |
||
|
|
|||
| 40 | $this->id = $id; |
||
| 41 | $this->message = $message; |
||
| 42 | |||
| 43 | if (!is_int(preg_match($this->pattern, ''))) |
||
| 44 | throw new \Exception('Invalid pattern ' . $pattern . ' for check ' . $id); |
||
| 45 | } |
||
| 46 | |||
| 52 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: