Skip to content

Commit 1c8546e

Browse files
committed
Making PHPCS changes
1 parent 93395d0 commit 1c8546e

9 files changed

Lines changed: 44 additions & 41 deletions

Commands/WarmDeviceDetectorCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class WarmDeviceDetectorCache extends ConsoleCommand
2020
{
21-
const COMMAND_NAME = 'device-detector-cache:warm-cache';
21+
public const COMMAND_NAME = 'device-detector-cache:warm-cache';
2222
/**
2323
* @var Configuration
2424
*/

Configuration.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
class Configuration
1515
{
16-
const KEY_NumEntriesToCache = 'num_cache_entries';
17-
const DEFAULT_NumEntriesToCache = 200000;
16+
public const KEY_NUM_ENTRIES_TO_CACHE = 'num_cache_entries';
17+
public const DEFAULT_NUM_ENTRIES_TO_CACHE = 200000;
1818

19-
const KEY_AccessLogRegex = 'access_log_regex';
20-
const DEFAULT_AccessLogRegex = '/^(\S+) (\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) "([^"]*)" "([^"]*)" (\d+)$/';
19+
public const KEY_ACCESS_LOG_REGEX = 'access_log_regex';
20+
public const DEFAULT_ACCESS_LOG_REGEX = '/^(\S+) (\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) "([^"]*)" "([^"]*)" (\d+)$/';
2121

22-
const KEY_AccessLogRegexMatchEntry = 'regex_match_entry';
23-
const DEFAULT_AccessLogRegexMatchEntry = 14;
22+
public const KEY_ACCESS_LOG_REGEX_MATCH_ENTRY = 'regex_match_entry';
23+
public const DEFAULT_ACCESS_LOG_REGEX_MATCH_ENTRY = 14;
2424

25-
const KEY_AccessLogPath = 'access_log_path';
26-
const DEFAULT_AccessLogPath = '/var/log/httpd/access_log';
25+
public const KEY_ACCESS_LOG_PATH = 'access_log_path';
26+
public const DEFAULT_ACCESS_LOG_PATH = '/var/log/httpd/access_log';
2727

2828
public function install()
2929
{
@@ -36,17 +36,17 @@ public function install()
3636
$cache = $config->DeviceDetectorCache;
3737

3838
// we make sure to set a value only if none has been configured yet, eg in common config.
39-
if (empty($cache[self::KEY_NumEntriesToCache])) {
40-
$cache[self::KEY_NumEntriesToCache] = self::DEFAULT_NumEntriesToCache;
39+
if (empty($cache[self::KEY_NUM_ENTRIES_TO_CACHE])) {
40+
$cache[self::KEY_NUM_ENTRIES_TO_CACHE] = self::DEFAULT_NUM_ENTRIES_TO_CACHE;
4141
}
42-
if (empty($cache[self::KEY_AccessLogPath])) {
43-
$cache[self::KEY_AccessLogPath] = self::DEFAULT_AccessLogPath;
42+
if (empty($cache[self::KEY_ACCESS_LOG_PATH])) {
43+
$cache[self::KEY_ACCESS_LOG_PATH] = self::DEFAULT_ACCESS_LOG_PATH;
4444
}
45-
if (empty($cache[self::KEY_AccessLogRegex])) {
46-
$cache[self::KEY_AccessLogRegex] = self::DEFAULT_AccessLogRegex;
45+
if (empty($cache[self::KEY_ACCESS_LOG_REGEX])) {
46+
$cache[self::KEY_ACCESS_LOG_REGEX] = self::DEFAULT_ACCESS_LOG_REGEX;
4747
}
48-
if (empty($cache[self::KEY_AccessLogRegexMatchEntry])) {
49-
$cache[self::KEY_AccessLogRegexMatchEntry] = self::DEFAULT_AccessLogRegexMatchEntry;
48+
if (empty($cache[self::KEY_ACCESS_LOG_REGEX_MATCH_ENTRY])) {
49+
$cache[self::KEY_ACCESS_LOG_REGEX_MATCH_ENTRY] = self::DEFAULT_ACCESS_LOG_REGEX_MATCH_ENTRY;
5050
}
5151

5252
$config->DeviceDetectorCache = $cache;
@@ -66,31 +66,31 @@ public function uninstall()
6666
*/
6767
public function getAccessLogPath()
6868
{
69-
return $this->getConfigValue(self::KEY_AccessLogPath, self::DEFAULT_AccessLogPath);
69+
return $this->getConfigValue(self::KEY_ACCESS_LOG_PATH, self::DEFAULT_ACCESS_LOG_PATH);
7070
}
7171

7272
/**
7373
* @return string
7474
*/
7575
public function getAccessLogRegex()
7676
{
77-
return $this->getConfigValue(self::KEY_AccessLogRegex, self::DEFAULT_AccessLogRegex);
77+
return $this->getConfigValue(self::KEY_ACCESS_LOG_REGEX, self::DEFAULT_ACCESS_LOG_REGEX);
7878
}
7979

8080
/**
8181
* @return string
8282
*/
8383
public function getRegexMatchEntry()
8484
{
85-
return (int)$this->getConfigValue(self::KEY_AccessLogRegexMatchEntry, self::DEFAULT_AccessLogRegexMatchEntry);
85+
return (int)$this->getConfigValue(self::KEY_ACCESS_LOG_REGEX_MATCH_ENTRY, self::DEFAULT_ACCESS_LOG_REGEX_MATCH_ENTRY);
8686
}
8787

8888
/**
8989
* @return string
9090
*/
9191
public function getNumEntriesToCache()
9292
{
93-
return (int)$this->getConfigValue(self::KEY_NumEntriesToCache, self::DEFAULT_NumEntriesToCache);
93+
return (int)$this->getConfigValue(self::KEY_NUM_ENTRIES_TO_CACHE, self::DEFAULT_NUM_ENTRIES_TO_CACHE);
9494
}
9595

9696
private function getConfig()

DeviceDetector/CachedBrowserParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ protected function parseBrowserFromUserAgent(): array
2929

3030
return parent::parseBrowserFromUserAgent();
3131
}
32-
}
32+
}

DeviceDetector/CachedOperatingSystemParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ protected function parseOsFromUserAgent(): array
2929

3030
return parent::parseOsFromUserAgent();
3131
}
32-
}
32+
}

Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Matomo - free/libre analytics platform
45
*
@@ -21,4 +22,4 @@ protected function getDeviceDetectionInfo($userAgent, array $clientHints = [])
2122

2223
return parent::getDeviceDetectionInfo($userAgent, $clientHints);
2324
}
24-
}
25+
}

tests/Integration/CachedEntryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public function testConstructSomeValues()
4646
$values = [
4747
'bot' => 'testBot',
4848
'brand' => 'testBrand',
49-
'client'=> 'testClient',
50-
'device'=> 2,
51-
'model'=> 'testModel',
49+
'client' => 'testClient',
50+
'device' => 2,
51+
'model' => 'testModel',
5252
'os' => 'testOs',
5353
];
5454

tests/Integration/ConfigurationTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,59 +42,59 @@ public function test_shouldInstallConfig()
4242
$this->assertEquals([
4343
'num_cache_entries' => '200000',
4444
'access_log_path' => '/var/log/httpd/access_log',
45-
'access_log_regex' => Configuration::DEFAULT_AccessLogRegex,
45+
'access_log_regex' => Configuration::DEFAULT_ACCESS_LOG_REGEX,
4646
'regex_match_entry' => 14,
4747
], $configs);
4848
}
4949

5050
public function test_getRegexMatchEntry()
5151
{
52-
$this->assertSame(Configuration::DEFAULT_AccessLogRegexMatchEntry, $this->configuration->getRegexMatchEntry());
52+
$this->assertSame(Configuration::DEFAULT_ACCESS_LOG_REGEX_MATCH_ENTRY, $this->configuration->getRegexMatchEntry());
5353
}
5454

5555
public function test_getRegexMatchEntry_customValue()
5656
{
5757
Config::getInstance()->DeviceDetectorCache = [
58-
Configuration::KEY_AccessLogRegexMatchEntry => '5',
58+
Configuration::KEY_ACCESS_LOG_REGEX_MATCH_ENTRY => '5',
5959
];
6060
$this->assertEquals(5, $this->configuration->getRegexMatchEntry());
6161
}
6262

6363
public function test_getAccessLogPath()
6464
{
65-
$this->assertSame(Configuration::DEFAULT_AccessLogPath, $this->configuration->getAccessLogPath());
65+
$this->assertSame(Configuration::DEFAULT_ACCESS_LOG_PATH, $this->configuration->getAccessLogPath());
6666
}
6767

6868
public function test_getAccessLogPath_customValue()
6969
{
7070
Config::getInstance()->DeviceDetectorCache = [
71-
Configuration::KEY_AccessLogPath => '/var/log/foo',
71+
Configuration::KEY_ACCESS_LOG_PATH => '/var/log/foo',
7272
];
7373
$this->assertEquals('/var/log/foo', $this->configuration->getAccessLogPath());
7474
}
7575

7676
public function test_getNumEntriesToCache()
7777
{
78-
$this->assertSame(Configuration::DEFAULT_NumEntriesToCache, $this->configuration->getNumEntriesToCache());
78+
$this->assertSame(Configuration::DEFAULT_NUM_ENTRIES_TO_CACHE, $this->configuration->getNumEntriesToCache());
7979
}
8080

8181
public function test_getNumEntriesToCache_customValue()
8282
{
8383
Config::getInstance()->DeviceDetectorCache = [
84-
Configuration::KEY_NumEntriesToCache => '145',
84+
Configuration::KEY_NUM_ENTRIES_TO_CACHE => '145',
8585
];
8686
$this->assertEquals(145, $this->configuration->getNumEntriesToCache());
8787
}
8888

8989
public function test_getAccessLogRegex()
9090
{
91-
$this->assertSame(Configuration::DEFAULT_AccessLogRegex, $this->configuration->getAccessLogRegex());
91+
$this->assertSame(Configuration::DEFAULT_ACCESS_LOG_REGEX, $this->configuration->getAccessLogRegex());
9292
}
9393

9494
public function test_getAccessLogRegex_customValue()
9595
{
9696
Config::getInstance()->DeviceDetectorCache = [
97-
Configuration::KEY_AccessLogRegex => '(.*)',
97+
Configuration::KEY_ACCESS_LOG_REGEX => '(.*)',
9898
];
9999
$this->assertEquals('(.*)', $this->configuration->getAccessLogRegex());
100100
}

tests/Integration/WarmDeviceDetectorCacheTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Matomo - free/libre analytics platform
45
*
@@ -26,7 +27,7 @@ class WarmDeviceDetectorCacheTest extends ConsoleCommandTestCase
2627
public function setUp(): void
2728
{
2829
parent::setUp();
29-
CachedEntry::setCacheDir(PIWIK_DOCUMENT_ROOT. '/tmp/devicecachetests/');
30+
CachedEntry::setCacheDir(PIWIK_DOCUMENT_ROOT . '/tmp/devicecachetests/');
3031
CachedEntry::clearCacheDir();
3132
}
3233

@@ -41,15 +42,15 @@ private function setAccessLogFile($file)
4142
{
4243
$config = \Piwik\Config::getInstance();
4344
$d = $config->DeviceDetectorCache;
44-
$d[Configuration::KEY_AccessLogPath] = $file;
45+
$d[Configuration::KEY_ACCESS_LOG_PATH] = $file;
4546
$config->DeviceDetectorCache = $d;
4647
}
4748

4849
private function setCountProcessNumEntries($numEntries)
4950
{
5051
$config = \Piwik\Config::getInstance();
5152
$d = $config->DeviceDetectorCache;
52-
$d[Configuration::KEY_NumEntriesToCache] = $numEntries;
53+
$d[Configuration::KEY_NUM_ENTRIES_TO_CACHE] = $numEntries;
5354
$config->DeviceDetectorCache = $d;
5455
}
5556

@@ -203,4 +204,4 @@ private function assertUserAgentWrittenToFile($userAgent)
203204
$this->assertEquals($deviceDetectionParsed->getModel(), $deviceDetectionFromFile->getModel());
204205
$this->assertEquals($deviceDetectionParsed->getOs(), $deviceDetectionFromFile->getOs());
205206
}
206-
}
207+
}

tests/System/CheckDirectDependencyUseCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Piwik - free/libre analytics platform
45
*
@@ -49,4 +50,4 @@ public function testCommand()
4950
]
5051
], $checkDirectDependencyUse->usesFoundList[$pluginName]);
5152
}
52-
}
53+
}

0 commit comments

Comments
 (0)