@@ -45,7 +45,7 @@ |
||
45 | 45 | $testClass->callStatic( |
46 | 46 | $className, $methodName, $this->urlsToTest |
47 | 47 | ), true |
48 | - )["status"]; |
|
48 | + )[ "status" ]; |
|
49 | 49 | |
50 | 50 | $this->assertEquals($expected, $actual); |
51 | 51 | } |
@@ -43,29 +43,29 @@ 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 | |
55 | 55 | $this->assertEquals($expected, $actual); |
56 | 56 | } |
57 | 57 | |
58 | - public function testRemoveAllUrls(){ |
|
58 | + public function testRemoveAllUrls() { |
|
59 | 59 | $this->safeUrls->add($this->urlsToTest); |
60 | 60 | |
61 | - $expected = []; |
|
61 | + $expected = [ ]; |
|
62 | 62 | $this->safeUrls->remove($this->urlsToTest); |
63 | 63 | $actual = $this->safeUrls->getCurrentUrls(true); |
64 | 64 | |
65 | 65 | $this->assertEquals($expected, $actual); |
66 | 66 | } |
67 | 67 | |
68 | - public function testExecute(){ |
|
68 | + public function testExecute() { |
|
69 | 69 | |
70 | 70 | // Only testing with returned HTTP status, as Google Safebrowsing API not working as |
71 | 71 | // documented. See tests\Libraries\Curl\CurlTest testMalwareSocialEngineeringAnyPlatformUrl(). |
@@ -74,24 +74,24 @@ discard block |
||
74 | 74 | |
75 | 75 | $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" } ] } }'; |
76 | 76 | |
77 | - $expected = json_decode($expected, true)["status"]; |
|
78 | - $actual = json_decode((string)$this->safeUrls->execute()->getResults(), true)["status"]; |
|
77 | + $expected = json_decode($expected, true)[ "status" ]; |
|
78 | + $actual = json_decode((string) $this->safeUrls->execute()->getResults(), true)[ "status" ]; |
|
79 | 79 | |
80 | 80 | $this->assertEquals($expected, $actual); |
81 | 81 | |
82 | 82 | } |
83 | 83 | |
84 | - public function testGetResults(){ |
|
84 | + public function testGetResults() { |
|
85 | 85 | |
86 | 86 | $this->testExecute(); |
87 | 87 | } |
88 | 88 | |
89 | - public function testCheck(){ |
|
89 | + public function testCheck() { |
|
90 | 90 | |
91 | 91 | $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" } ] } }'; |
92 | - $expected = json_decode($expected, true)["status"]; |
|
92 | + $expected = json_decode($expected, true)[ "status" ]; |
|
93 | 93 | |
94 | - $actual = json_decode($this->safeUrls::check($this->urlsToTest), true)["status"]; |
|
94 | + $actual = json_decode($this->safeUrls::check($this->urlsToTest), true)[ "status" ]; |
|
95 | 95 | |
96 | 96 | $this->assertEquals($expected, $actual); |
97 | 97 | } |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @expectedException \ErrorException |
101 | 101 | */ |
102 | - public function testCheckThrowErrorException(){ |
|
102 | + public function testCheckThrowErrorException() { |
|
103 | 103 | $this->safeUrls->add($this->urlsToTest); |
104 | 104 | |
105 | 105 | $safeUrlsMock = $this->getMockBuilder(SafeUrls::class) |
106 | - ->setMethods(['callStatic']) |
|
106 | + ->setMethods([ 'callStatic' ]) |
|
107 | 107 | ->getMock(); |
108 | 108 | |
109 | 109 | $safeUrlsMock->method("callStatic") |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - public function testIsDangerous(){ |
|
117 | + public function testIsDangerous() { |
|
118 | 118 | $this->safeUrls->add($this->urlsToTest); |
119 | 119 | $this->safeUrls->execute(); |
120 | 120 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function register() |
45 | 45 | { |
46 | 46 | // Register the service the package provides. |
47 | - $this->app->singleton('safe-urls', function () { |
|
47 | + $this->app->singleton('safe-urls', function() { |
|
48 | 48 | return new SafeUrls(); |
49 | 49 | }); |
50 | 50 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function provides() |
58 | 58 | { |
59 | - return ['safe-urls']; |
|
59 | + return [ 'safe-urls' ]; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ], 'safe-urls'); |
73 | 73 | |
74 | 74 | // Registering package commands. |
75 | - $this->commands(['safe-urls']); |
|
75 | + $this->commands([ 'safe-urls' ]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function mergeConfigFrom($path, $key) |
87 | 87 | { |
88 | - $config = $this->app['config']->get($key, []); |
|
89 | - $this->app['config']->set($key, $this->mergeConfig($config, require $path)); |
|
88 | + $config = $this->app[ 'config' ]->get($key, [ ]); |
|
89 | + $this->app[ 'config' ]->set($key, $this->mergeConfig($config, require $path)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | if (is_numeric($key)) { |
111 | 111 | continue; |
112 | 112 | } |
113 | - $array[$key] = $this->mergeConfig($value, $merging[$key]); |
|
113 | + $array[ $key ] = $this->mergeConfig($value, $merging[ $key ]); |
|
114 | 114 | } |
115 | 115 | return $array; |
116 | 116 | } |
@@ -20,6 +20,6 @@ |
||
20 | 20 | $parameters = func_get_args(); |
21 | 21 | $parameters = array_slice($parameters, 2); // Remove $className and $methodName |
22 | 22 | |
23 | - return call_user_func_array($className . '::' . $methodName, $parameters); |
|
23 | + return call_user_func_array($className.'::'.$methodName, $parameters); |
|
24 | 24 | } |
25 | 25 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array The generated payload. |
28 | 28 | */ |
29 | - public static function payload(array $urls, array $threatTypes = [], array $platformTypes = [], array $threatEntryTypes = []): array |
|
29 | + public static function payload(array $urls, array $threatTypes = [ ], array $platformTypes = [ ], array $threatEntryTypes = [ ]): array |
|
30 | 30 | { |
31 | 31 | return [ |
32 | 32 | 'client' => [ |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public static function formatUrls(array $urls): array |
53 | 53 | { |
54 | - $formattedUrls = []; |
|
54 | + $formattedUrls = [ ]; |
|
55 | 55 | foreach ($urls as $url) { |
56 | - $formattedUrls[] = ['url' => $url]; |
|
56 | + $formattedUrls[ ] = [ 'url' => $url ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $formattedUrls; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function googleApiUrl() |
68 | 68 | { |
69 | - return 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key=' . |
|
69 | + return 'https://safebrowsing.googleapis.com/v4/threatMatches:find?key='. |
|
70 | 70 | Config::googleApiKey(); |
71 | 71 | } |
72 | 72 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | public function __construct() |
36 | 36 | { |
37 | 37 | // Initialise the list of urls as an empty array. |
38 | - $this->urls = []; |
|
38 | + $this->urls = [ ]; |
|
39 | 39 | |
40 | 40 | // Initialise the list of urls as an empty array. |
41 | - $this->results = []; |
|
41 | + $this->results = [ ]; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return array|string The set of results, in JSON. |
68 | 68 | */ |
69 | - public function checkCallStatic(array $urls){ |
|
69 | + public function checkCallStatic(array $urls) { |
|
70 | 70 | |
71 | 71 | return $this->callStatic(SafeUrls::class, "check", $urls); |
72 | 72 | } |
73 | 73 | |
74 | - public function execute(){ |
|
74 | + public function execute() { |
|
75 | 75 | $this->results = SafeUrls::check($this->urls); |
76 | 76 | return $this; |
77 | 77 | } |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array|string |
113 | 113 | */ |
114 | - public function getCurrentUrls(bool $asArray = false){ |
|
115 | - return $asArray == false ? json_encode($this->urls): $this->urls; |
|
114 | + public function getCurrentUrls(bool $asArray = false) { |
|
115 | + return $asArray == false ? json_encode($this->urls) : $this->urls; |
|
116 | 116 | } |
117 | 117 | |
118 | - public function getResults(){ |
|
118 | + public function getResults() { |
|
119 | 119 | return $this->results; |
120 | 120 | } |
121 | 121 | /** |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function isDangerous(string $url): bool |
130 | 130 | { |
131 | - $data = json_decode((string)$this->results); |
|
132 | - $matches = empty($data->response["matches"]) ? null : $data->response["matches"]; |
|
133 | - if(empty($matches)){ |
|
131 | + $data = json_decode((string) $this->results); |
|
132 | + $matches = empty($data->response[ "matches" ]) ? null : $data->response[ "matches" ]; |
|
133 | + if (empty($matches)) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | foreach ($matches as $result) { |