This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
18
/**
19
* @inheritdoc
20
*/
21
public function init() {
22
parent::init();
23
if ($this->message === null) {
24
$this->message = Yii::t('yii', "{attribute} is invalid.");
25
}
26
}
27
28
public function validateAttribute($model, $attribute) {
29
$string = $model->{$attribute};
30
31
// filter_var suxx
32
if (!preg_match('/^([0-9a-F]{1,2}[\.:-]){5}([0-9a-F]{1,2})$/', $string)) {
33
$this->addError($model, $attribute, Yii::t('yii', 'This in not valid MAC address {sample}', ['sample' => '00:00:00:00:00:01']));
It is not recommended to use PHP's closing tag ?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended
as you might accidentally add whitespace after the closing tag which would then
be output by PHP. This can cause severe problems, for example headers cannot be
sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and
it also has no negative effects whatsoever.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.