@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function __construct(\SimpleXMLElement $xmlData) |
| 70 | 70 | { |
| 71 | - if($xmlData !== null) |
|
| 71 | + if ($xmlData !== null) |
|
| 72 | 72 | { |
| 73 | 73 | foreach ($xmlData->children() as $child) |
| 74 | 74 | { |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function loadFromFile() |
| 86 | 86 | { |
| 87 | - $path = str_replace('src','data',__DIR__).'/deviceModels.xml'; |
|
| 87 | + $path = str_replace('src', 'data', __DIR__).'/deviceModels.xml'; |
|
| 88 | 88 | $models = array(); |
| 89 | 89 | $xmlObj = simplexml_load_file($path); |
| 90 | - foreach($xmlObj->children() as $rule) |
|
| 90 | + foreach ($xmlObj->children() as $rule) |
|
| 91 | 91 | { |
| 92 | 92 | $models[] = new self($rule); |
| 93 | 93 | } |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function __construct(\SimpleXMLElement $xmlData) |
| 58 | 58 | { |
| 59 | - if($xmlData !== null) |
|
| 59 | + if ($xmlData !== null) |
|
| 60 | 60 | { |
| 61 | 61 | foreach ($xmlData->children() as $child) { |
| 62 | 62 | switch ($child->getName()) { |
@@ -72,19 +72,19 @@ |
||
| 72 | 72 | { |
| 73 | 73 | parent::__construct($xmlData); |
| 74 | 74 | |
| 75 | - if($xmlData !== null) |
|
| 75 | + if ($xmlData !== null) |
|
| 76 | 76 | { |
| 77 | 77 | foreach ($xmlData->children() as $child) |
| 78 | 78 | { |
| 79 | 79 | $name = $child->getName(); |
| 80 | 80 | $val = $child->__toString(); |
| 81 | - if($name != 'id' && $name != 'pattern' && $name != 'SearchEngine') |
|
| 81 | + if ($name != 'id' && $name != 'pattern' && $name != 'SearchEngine') |
|
| 82 | 82 | { |
| 83 | 83 | $this->$name = $val; |
| 84 | 84 | } |
| 85 | - if($name == 'SearchEngine') |
|
| 85 | + if ($name == 'SearchEngine') |
|
| 86 | 86 | { |
| 87 | - if($val == 'true') |
|
| 87 | + if ($val == 'true') |
|
| 88 | 88 | { |
| 89 | 89 | $this->setSearchEngine(true); |
| 90 | 90 | } |
@@ -87,9 +87,9 @@ |
||
| 87 | 87 | if($val == 'true') |
| 88 | 88 | { |
| 89 | 89 | $this->setSearchEngine(true); |
| 90 | + } else { |
|
| 91 | + $this->setSearchEngine(false); |
|
| 90 | 92 | } |
| 91 | - else |
|
| 92 | - $this->setSearchEngine(false); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct(\SimpleXMLElement $xmlData) |
| 23 | 23 | { |
| 24 | - if($xmlData === null || $xmlData->getName() == 'null') |
|
| 24 | + if ($xmlData === null || $xmlData->getName() == 'null') |
|
| 25 | 25 | { |
| 26 | 26 | parent::__construct($xmlData); |
| 27 | 27 | |
@@ -43,8 +43,7 @@ |
||
| 43 | 43 | |
| 44 | 44 | $this->setName('Desktop'); |
| 45 | 45 | $this->setType('desktop'); |
| 46 | - } |
|
| 47 | - else |
|
| 46 | + } else |
|
| 48 | 47 | { |
| 49 | 48 | parent::__construct($xmlData); |
| 50 | 49 | |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public function __construct(\SimpleXMLElement $xmlData) |
| 106 | 106 | { |
| 107 | - if($xmlData !== null) |
|
| 107 | + if ($xmlData !== null) |
|
| 108 | 108 | { |
| 109 | 109 | foreach ($xmlData->children() as $child) |
| 110 | 110 | { |
| 111 | 111 | $name = $child->getName(); |
| 112 | 112 | $val = $child->__toString(); |
| 113 | - if($name != 'TargetValue') |
|
| 113 | + if ($name != 'TargetValue') |
|
| 114 | 114 | { |
| 115 | 115 | $this->$name = $val; |
| 116 | 116 | } |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public static function loadRulesFromFile() |
| 127 | 127 | { |
| 128 | - $path = str_replace('src','data',__DIR__).'/rules/'; |
|
| 128 | + $path = str_replace('src', 'data', __DIR__).'/rules/'; |
|
| 129 | 129 | $files = scandir($path); |
| 130 | 130 | $rules = array(); |
| 131 | - foreach($files as $file) |
|
| 131 | + foreach ($files as $file) |
|
| 132 | 132 | { |
| 133 | - if($file != '.' && $file != '..') |
|
| 133 | + if ($file != '.' && $file != '..') |
|
| 134 | 134 | { |
| 135 | 135 | $xmlObj = simplexml_load_file($path.$file); |
| 136 | - foreach($xmlObj->children() as $rule) |
|
| 136 | + foreach ($xmlObj->children() as $rule) |
|
| 137 | 137 | { |
| 138 | 138 | $rules[] = new self($rule); |
| 139 | 139 | } |
@@ -113,9 +113,9 @@ |
||
| 113 | 113 | if($name != 'TargetValue') |
| 114 | 114 | { |
| 115 | 115 | $this->$name = $val; |
| 116 | + } else { |
|
| 117 | + $this->$name = filter_var($val, FILTER_VALIDATE_BOOLEAN); |
|
| 116 | 118 | } |
| 117 | - else |
|
| 118 | - $this->$name = filter_var($val, FILTER_VALIDATE_BOOLEAN); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function __construct(\SimpleXMLElement $xmlData) |
| 23 | 23 | { |
| 24 | 24 | parent::__construct($xmlData); |
| 25 | - if($xmlData !== null) |
|
| 25 | + if ($xmlData !== null) |
|
| 26 | 26 | { |
| 27 | 27 | foreach ($xmlData->children() as $child) { |
| 28 | 28 | switch ($child->getName()) { |
@@ -46,6 +46,6 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -define('UNX','unix'); |
|
| 50 | -define('WIN','windows'); |
|
| 51 | -define('MC','mac'); |
|
| 49 | +define('UNX', 'unix'); |
|
| 50 | +define('WIN', 'windows'); |
|
| 51 | +define('MC', 'mac'); |
|
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $parameters = []; |
| 39 | 39 | $parser = new Parser(); |
| 40 | - $dataDir = \dirname(__DIR__) . '/var/data/'; |
|
| 40 | + $dataDir = \dirname(__DIR__).'/var/data/'; |
|
| 41 | 41 | foreach (new \DirectoryIterator($dataDir) as $file) { |
| 42 | 42 | if ($file->getExtension() === '.yml') { |
| 43 | 43 | $data = $parser->parseFile($file->getRealPath()); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function getParameter(string $name): array |
| 57 | 57 | { |
| 58 | 58 | if (!array_key_exists($name, $this->parameters)) { |
| 59 | - throw new DetectorException(sprintf('% not exist in data' . $name), 1); |
|
| 59 | + throw new DetectorException(sprintf('% not exist in data'.$name), 1); |
|
| 60 | 60 | } |
| 61 | 61 | return $this->parameters[$name]; |
| 62 | 62 | } |