| Total Complexity | 13 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 14 | class IpFilter extends Filter |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var array|string |
||
| 18 | */ |
||
| 19 | public $ips; |
||
| 20 | /** |
||
| 21 | * @var Request|null |
||
| 22 | */ |
||
| 23 | protected $request; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @inheritdoc |
||
| 27 | */ |
||
| 28 | public function init() |
||
| 29 | { |
||
| 30 | if (Yii::$app instanceof Application) { |
||
| 31 | $this->request = Yii::$app->request; |
||
| 32 | } |
||
| 33 | if (is_string($this->ips)) { |
||
| 34 | $this->ips = [$this->ips]; |
||
| 35 | } |
||
| 36 | parent::init(); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return bool |
||
| 41 | */ |
||
| 42 | public function isAllowed() |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Check IP (mask supported). |
||
| 57 | * @param string $filter |
||
| 58 | * @param string $ip |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | protected function checkIp($filter, $ip) |
||
| 65 | } |
||
| 66 | } |
||
| 67 |