diff --git a/Makefile b/Makefile index 04cde88..2bd666d 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ fix: lint: php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs --dry-run + php $(HERE)/vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode + php $(HERE)/vendor/bin/phpmd tests/ text cleancode,codesize,controversial,design,naming,unusedcode test: php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml diff --git a/src/Configurations/PageRulesActions.php b/src/Configurations/PageRulesActions.php index cdb03c8..c52ddc1 100644 --- a/src/Configurations/PageRulesActions.php +++ b/src/Configurations/PageRulesActions.php @@ -159,12 +159,12 @@ class PageRulesActions implements Configurations ]); } - public function setMinification(bool $html, bool $css, bool $js) + public function setMinification(bool $html, bool $css, bool $javascript) { $this->addConfigurationOption("minification", [ 'html' => $this->getBoolAsOnOrOff($html), 'css' => $this->getBoolAsOnOrOff($css), - 'js' => $this->getBoolAsOnOrOff($js), + 'js' => $this->getBoolAsOnOrOff($javascript), ]); } @@ -297,9 +297,9 @@ class PageRulesActions implements Configurations return $this->configs; } - private function addConfigurationOption($id, array $configuration) + private function addConfigurationOption(string $setting, array $configuration) { - $configuration['id'] = $id; + $configuration['id'] = $setting; array_push($this->configs, (object) $configuration); } diff --git a/src/Endpoints/DNS.php b/src/Endpoints/DNS.php index 9adb9aa..ff4b5bf 100644 --- a/src/Endpoints/DNS.php +++ b/src/Endpoints/DNS.php @@ -19,6 +19,17 @@ class DNS implements API $this->adapter = $adapter; } + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param string $type + * @param string $name + * @param string $content + * @param int $ttl + * @param bool $proxied + * @return bool + */ public function addRecord( string $zoneID, string $type, diff --git a/src/Endpoints/PageRules.php b/src/Endpoints/PageRules.php index d171c61..c8be3ab 100644 --- a/src/Endpoints/PageRules.php +++ b/src/Endpoints/PageRules.php @@ -21,6 +21,16 @@ class PageRules implements API $this->adapter = $adapter; } + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param PageRulesTargets $target + * @param PageRulesActions $actions + * @param bool $active + * @param int|null $priority + * @return bool + */ public function createPageRule( string $zoneID, PageRulesTargets $target, diff --git a/src/Endpoints/UARules.php b/src/Endpoints/UARules.php index 8741eab..0da89a9 100644 --- a/src/Endpoints/UARules.php +++ b/src/Endpoints/UARules.php @@ -43,7 +43,7 @@ class UARules implements API string $zoneID, string $mode, \Cloudflare\API\Configurations\Configurations $configuration, - string $id = null, + string $ruleID = null, string $description = null ): bool { $options = [ @@ -51,8 +51,8 @@ class UARules implements API 'configurations' => $configuration->getArray() ]; - if ($id !== null) { - $options['id'] = $id; + if ($ruleID !== null) { + $options['id'] = $ruleID; } if ($description !== null) { diff --git a/src/Endpoints/ZoneLockdown.php b/src/Endpoints/ZoneLockdown.php index 985d232..a827e59 100644 --- a/src/Endpoints/ZoneLockdown.php +++ b/src/Endpoints/ZoneLockdown.php @@ -43,7 +43,7 @@ class ZoneLockdown implements API string $zoneID, array $urls, \Cloudflare\API\Configurations\ZoneLockdown $configuration, - string $id = null, + string $lockdownID = null, string $description = null ): bool { $options = [ @@ -51,8 +51,8 @@ class ZoneLockdown implements API 'configurations' => $configuration->getArray() ]; - if ($id !== null) { - $options['id'] = $id; + if ($lockdownID !== null) { + $options['id'] = $lockdownID; } if ($description !== null) { diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php index da9ddfe..d0a87c7 100644 --- a/src/Endpoints/Zones.php +++ b/src/Endpoints/Zones.php @@ -19,6 +19,14 @@ class Zones implements API $this->adapter = $adapter; } + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $name + * @param bool $jumpstart + * @param string $organizationID + * @return \stdClass + */ public function addZone(string $name, bool $jumpstart = false, string $organizationID = ''): \stdClass { $options = [ diff --git a/tests/Adapter/GuzzleTest.php b/tests/Adapter/GuzzleTest.php index ba4d58e..de97374 100644 --- a/tests/Adapter/GuzzleTest.php +++ b/tests/Adapter/GuzzleTest.php @@ -133,6 +133,6 @@ class GuzzleTest extends TestCase public function testNotFound() { $this->expectException(\GuzzleHttp\Exception\RequestException::class); - $response = $this->client->get('https://httpbin.org/status/404'); + $this->client->get('https://httpbin.org/status/404'); } } diff --git a/tests/Endpoints/PageRulesTest.php b/tests/Endpoints/PageRulesTest.php index f4ee4ba..7c580d0 100644 --- a/tests/Endpoints/PageRulesTest.php +++ b/tests/Endpoints/PageRulesTest.php @@ -34,8 +34,8 @@ class PageRulesTest extends TestCase ]) ); - $pr = new \Cloudflare\API\Endpoints\PageRules($mock); - $result = $pr->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); $this->assertTrue($result); } @@ -60,8 +60,8 @@ class PageRulesTest extends TestCase $this->equalTo([]) ); - $pr = new \Cloudflare\API\Endpoints\PageRules($mock); - $pr->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all'); + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $pageRules->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all'); } public function testGetPageRuleDetails() @@ -78,8 +78,8 @@ class PageRulesTest extends TestCase $this->equalTo([]) ); - $pr = new \Cloudflare\API\Endpoints\PageRules($mock); - $pr->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $pageRules->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); } public function testUpdatePageRule() @@ -106,8 +106,8 @@ class PageRulesTest extends TestCase ]) ); - $pr = new \Cloudflare\API\Endpoints\PageRules($mock); - $result = $pr->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1); $this->assertTrue($result); } @@ -127,8 +127,8 @@ class PageRulesTest extends TestCase $this->equalTo([]) ); - $pr = new \Cloudflare\API\Endpoints\PageRules($mock); - $result = $pr->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); + $pageRules = new \Cloudflare\API\Endpoints\PageRules($mock); + $result = $pageRules->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac'); $this->assertTrue($result); } diff --git a/tests/Endpoints/UARulesTest.php b/tests/Endpoints/UARulesTest.php index 6854b2b..987069a 100644 --- a/tests/Endpoints/UARulesTest.php +++ b/tests/Endpoints/UARulesTest.php @@ -6,8 +6,6 @@ * Time: 15:19 */ -use Cloudflare\API\Endpoints\UARules; - class UARulesTest extends TestCase { public function testListRules() @@ -61,8 +59,8 @@ class UARulesTest extends TestCase ]) ); - $ld = new \Cloudflare\API\Endpoints\UARules($mock); - $ld->createRule( + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->createRule( '023e105f4ecef8ad9ca31a8372d0c353', 'js_challenge', $config, @@ -114,8 +112,8 @@ class UARulesTest extends TestCase ]) ); - $ld = new \Cloudflare\API\Endpoints\UARules($mock); - $ld->updateRule( + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->updateRule( '023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', 'js_challenge', @@ -139,7 +137,7 @@ class UARulesTest extends TestCase $this->equalTo([]) ); - $ld = new \Cloudflare\API\Endpoints\UARules($mock); - $ld->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + $rules = new \Cloudflare\API\Endpoints\UARules($mock); + $rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); } } diff --git a/tests/Endpoints/ZoneLockdownTest.php b/tests/Endpoints/ZoneLockdownTest.php index 4c7f314..066ebef 100644 --- a/tests/Endpoints/ZoneLockdownTest.php +++ b/tests/Endpoints/ZoneLockdownTest.php @@ -59,8 +59,8 @@ class ZoneLockdownTest extends TestCase ]) ); - $ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); - $ld->createLockdown( + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->createLockdown( '023e105f4ecef8ad9ca31a8372d0c353', ["api.mysite.com/some/endpoint*"], $config, @@ -112,8 +112,8 @@ class ZoneLockdownTest extends TestCase ]) ); - $ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); - $ld->updateLockdown( + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->updateLockdown( '023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59', ["api.mysite.com/some/endpoint*"], @@ -140,7 +140,7 @@ class ZoneLockdownTest extends TestCase $this->equalTo([]) ); - $ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); - $ld->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); + $zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock); + $zoneLockdown->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59'); } }