Completed
Pull Request — 4.0 (#40)
by Serhii
06:07 queued 04:20
created
src/Detector.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,6 @@
 block discarded – undo
12 12
 use EndorphinStudio\Detector\Data\AbstractData;
13 13
 use EndorphinStudio\Detector\Data\Result;
14 14
 use EndorphinStudio\Detector\Exception\StorageException;
15
-use EndorphinStudio\Detector\Storage\AbstractStorage;
16 15
 use EndorphinStudio\Detector\Storage\StorageInterface;
17 16
 use Symfony\Component\HttpFoundation\Request;
18 17
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 
103 103
         $this->init();
104 104
         $this->detectors = [];
105
-        $check = ['os','device', 'browser', 'robot'];
105
+        $check = ['os', 'device', 'browser', 'robot'];
106 106
         Tools::setWindowsConfig($this->dataProvider->getConfig()['windows']);
107 107
         foreach ($check as $detectionType) {
108 108
             $className = sprintf('\\EndorphinStudio\\Detector\\Detection\\%s', ucfirst(sprintf('%sDetector', $detectionType)));
109
-            if(class_exists($className)) {
109
+            if (class_exists($className)) {
110 110
                 $this->detectors[$detectionType] = new $className();
111 111
                 $this->detectors[$detectionType]->init($this);
112 112
             }
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
         /** @var StorageInterface $dataProvider */
153 153
         $this->setDataProvider($dataProvider);
154 154
         $this->dataProvider->setDataDirectory($this->findDataDirectory());
155
-        if(method_exists($this->dataProvider,'setCacheDirectory')) {
155
+        if (method_exists($this->dataProvider, 'setCacheDirectory')) {
156 156
             $this->dataProvider->setCacheDirectory($this->findCacheDirectory());
157 157
         }
158
-        if(method_exists($this->dataProvider,'setCacheEnabled')) {
158
+        if (method_exists($this->dataProvider, 'setCacheEnabled')) {
159 159
             $this->dataProvider->setCacheEnabled(true);
160 160
         }
161 161
     }
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     private function findDataDirectory(): string
169 169
     {
170 170
         $dataDirectory = $this->options['dataDirectory'];
171
-        if($this->options['dataDirectory'] === 'auto') {
171
+        if ($this->options['dataDirectory'] === 'auto') {
172 172
             $reflection = new \ReflectionClass(AbstractData::class);
173
-            $dataDirectory = sprintf('%s/var/%s', dirname($reflection->getFileName(),3), $this->options['format']);
173
+            $dataDirectory = sprintf('%s/var/%s', dirname($reflection->getFileName(), 3), $this->options['format']);
174 174
         }
175
-        if(is_dir($dataDirectory)){
175
+        if (is_dir($dataDirectory)) {
176 176
             return $dataDirectory;
177 177
         }
178 178
         throw new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $dataDirectory));
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
     private function findCacheDirectory(): string
187 187
     {
188 188
         $cacheDirectory = $this->options['cacheDirectory'];
189
-        if($this->options['cacheDirectory'] === 'auto') {
189
+        if ($this->options['cacheDirectory'] === 'auto') {
190 190
             $reflection = new \ReflectionClass(AbstractData::class);
191
-            $cacheDirectory = sprintf('%s/var/cache', dirname($reflection->getFileName(),3));
191
+            $cacheDirectory = sprintf('%s/var/cache', dirname($reflection->getFileName(), 3));
192 192
         }
193
-        if(is_dir($cacheDirectory)){
193
+        if (is_dir($cacheDirectory)) {
194 194
             return $cacheDirectory;
195 195
         }
196 196
         throw new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $cacheDirectory));
Please login to merge, or discard this patch.