@@ -15,6 +15,6 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | protected function getPackageProviders($app) |
| 17 | 17 | { |
| 18 | - return [SafeUrlsServiceProvider::class]; |
|
| 18 | + return [ SafeUrlsServiceProvider::class ]; |
|
| 19 | 19 | } |
| 20 | 20 | } |
@@ -18,13 +18,13 @@ |
||
| 18 | 18 | public const DEFAULT_TIMEOUT = 10; |
| 19 | 19 | |
| 20 | 20 | // Default threat types. |
| 21 | - public const DEFAULT_THREAT_TYPES = ['THREAT_TYPE_UNSPECIFIED']; |
|
| 21 | + public const DEFAULT_THREAT_TYPES = [ 'THREAT_TYPE_UNSPECIFIED' ]; |
|
| 22 | 22 | |
| 23 | 23 | // Default threst entry types. |
| 24 | - public const DEFAULT_THREAT_ENTRY_TYPES = ['THREAT_ENTRY_TYPE_UNSPECIFIED']; |
|
| 24 | + public const DEFAULT_THREAT_ENTRY_TYPES = [ 'THREAT_ENTRY_TYPE_UNSPECIFIED' ]; |
|
| 25 | 25 | |
| 26 | 26 | // Default threat platform types. |
| 27 | - public const DEFAULT_THREAT_PLATFORM_TYPES = ['PLATFORM_TYPE_UNSPECIFIED']; |
|
| 27 | + public const DEFAULT_THREAT_PLATFORM_TYPES = [ 'PLATFORM_TYPE_UNSPECIFIED' ]; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Retrieve the Google API key. |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | class DataTest extends TestCase |
| 11 | 11 | { |
| 12 | 12 | private $_formattedUrls = [ |
| 13 | - ['url' => 'https://www.google.com'], |
|
| 14 | - ['url' => 'https://github.com'], |
|
| 15 | - ['url' => 'https://github.styleci.io'], |
|
| 16 | - ['url' => 'https://travis-ci.org'], |
|
| 17 | - ['url' => 'https://packagist.org'], |
|
| 13 | + [ 'url' => 'https://www.google.com' ], |
|
| 14 | + [ 'url' => 'https://github.com' ], |
|
| 15 | + [ 'url' => 'https://github.styleci.io' ], |
|
| 16 | + [ 'url' => 'https://travis-ci.org' ], |
|
| 17 | + [ 'url' => 'https://packagist.org' ], |
|
| 18 | 18 | ]; |
| 19 | 19 | |
| 20 | 20 | private $_urls = [ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function testPayloadNoUrls() |
| 54 | 54 | { |
| 55 | - $urls = []; |
|
| 55 | + $urls = [ ]; |
|
| 56 | 56 | |
| 57 | 57 | $expected = self::_payload($urls); |
| 58 | 58 | |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | public function testFormatUrlsSingle() |
| 72 | 72 | { |
| 73 | - $url = ['https://www.google.com']; |
|
| 73 | + $url = [ 'https://www.google.com' ]; |
|
| 74 | 74 | |
| 75 | 75 | $expected = [ |
| 76 | - ['url' => 'https://www.google.com'], |
|
| 76 | + [ 'url' => 'https://www.google.com' ], |
|
| 77 | 77 | ]; |
| 78 | 78 | |
| 79 | 79 | $actual = Data::formatUrls($url); |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public function testFormatUrlsNone() |
| 84 | 84 | { |
| 85 | - $urls = []; |
|
| 85 | + $urls = [ ]; |
|
| 86 | 86 | |
| 87 | - $expected = []; |
|
| 87 | + $expected = [ ]; |
|
| 88 | 88 | |
| 89 | 89 | $actual = Data::formatUrls($urls); |
| 90 | 90 | $this->assertEquals($expected, $actual); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - private static function _payload(array $urls, array $threatTypes = [], array $platformTypes = [], array $threatEntryTypes = []): array |
|
| 93 | + private static function _payload(array $urls, array $threatTypes = [ ], array $platformTypes = [ ], array $threatEntryTypes = [ ]): array |
|
| 94 | 94 | { |
| 95 | 95 | return [ |
| 96 | 96 | 'client' => [ |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | $testClass->callStatic( |
| 47 | 47 | $className, $methodName, $this->urlsToTest |
| 48 | 48 | ), true |
| 49 | - )['status']; |
|
| 49 | + )[ 'status' ]; |
|
| 50 | 50 | |
| 51 | 51 | $this->assertEquals($expected, $actual); |
| 52 | 52 | } |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | $urlToRemove = 'https://testsafebrowsing.appspot.com/s/phishing.html'; |
| 44 | 44 | |
| 45 | 45 | $expected = [ |
| 46 | - $this->urlsToTest[1], |
|
| 47 | - $this->urlsToTest[2], |
|
| 48 | - $this->urlsToTest[3], |
|
| 49 | - $this->urlsToTest[4], |
|
| 46 | + $this->urlsToTest[ 1 ], |
|
| 47 | + $this->urlsToTest[ 2 ], |
|
| 48 | + $this->urlsToTest[ 3 ], |
|
| 49 | + $this->urlsToTest[ 4 ], |
|
| 50 | 50 | ]; |
| 51 | - $this->safeUrls->remove([$urlToRemove]); |
|
| 51 | + $this->safeUrls->remove([ $urlToRemove ]); |
|
| 52 | 52 | |
| 53 | 53 | $actual = $this->safeUrls->getCurrentUrls(true); |
| 54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $this->safeUrls->add($this->urlsToTest); |
| 61 | 61 | |
| 62 | - $expected = []; |
|
| 62 | + $expected = [ ]; |
|
| 63 | 63 | $this->safeUrls->remove($this->urlsToTest); |
| 64 | 64 | $actual = $this->safeUrls->getCurrentUrls(true); |
| 65 | 65 | |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $expected = '{ "status": 200, "response": { "matches": [ { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "https://testsafebrowsing.appspot.com/s/phishing.html" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "https://testsafebrowsing.appspot.com/s/malware.html" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/MALWARE/URL/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/SOCIAL_ENGINEERING/URL/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "http://malware.testing.google.test/testing/malware/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "http://malware.testing.google.test/testing/malware/" }, "cacheDuration": "300s", "threatEntryType": "URL" } ] } }'; |
| 78 | 78 | |
| 79 | - $expected = json_decode($expected, true)['status']; |
|
| 80 | - $actual = json_decode((string) $this->safeUrls->execute()->getResults(), true)['status']; |
|
| 79 | + $expected = json_decode($expected, true)[ 'status' ]; |
|
| 80 | + $actual = json_decode((string) $this->safeUrls->execute()->getResults(), true)[ 'status' ]; |
|
| 81 | 81 | |
| 82 | 82 | $this->assertEquals($expected, $actual); |
| 83 | 83 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | public function testCheck() |
| 91 | 91 | { |
| 92 | 92 | $expected = '{ "status": 200, "response": { "matches": [ { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "https://testsafebrowsing.appspot.com/s/phishing.html" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "https://testsafebrowsing.appspot.com/s/malware.html" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/MALWARE/URL/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "http://testsafebrowsing.appspot.com/apiv4/ANY_PLATFORM/SOCIAL_ENGINEERING/URL/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "MALWARE", "platformType": "ANY_PLATFORM", "threat": { "url": "http://malware.testing.google.test/testing/malware/" }, "cacheDuration": "300s", "threatEntryType": "URL" }, { "threatType": "SOCIAL_ENGINEERING", "platformType": "ANY_PLATFORM", "threat": { "url": "http://malware.testing.google.test/testing/malware/" }, "cacheDuration": "300s", "threatEntryType": "URL" } ] } }'; |
| 93 | - $expected = json_decode($expected, true)['status']; |
|
| 93 | + $expected = json_decode($expected, true)[ 'status' ]; |
|
| 94 | 94 | |
| 95 | - $actual = json_decode($this->safeUrls::check($this->urlsToTest), true)['status']; |
|
| 95 | + $actual = json_decode($this->safeUrls::check($this->urlsToTest), true)[ 'status' ]; |
|
| 96 | 96 | |
| 97 | 97 | $this->assertEquals($expected, $actual); |
| 98 | 98 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->safeUrls->add($this->urlsToTest); |
| 106 | 106 | |
| 107 | 107 | $safeUrlsMock = $this->getMockBuilder(SafeUrls::class) |
| 108 | - ->setMethods(['callStatic']) |
|
| 108 | + ->setMethods([ 'callStatic' ]) |
|
| 109 | 109 | ->getMock(); |
| 110 | 110 | |
| 111 | 111 | $safeUrlsMock->method('callStatic') |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | public function isDangerous(string $url): bool |
| 136 | 136 | { |
| 137 | 137 | $data = json_decode((string) $this->results); |
| 138 | - $matches = empty($data->response['matches']) ? null : $data->response['matches']; |
|
| 138 | + $matches = empty($data->response[ 'matches' ]) ? null : $data->response[ 'matches' ]; |
|
| 139 | 139 | if (empty($matches)) { |
| 140 | 140 | return false; |
| 141 | 141 | } |