Merge pull request #27 from cloudflare/phpmd
Enable PHPMD for src and tests
This commit is contained in:
2
Makefile
2
Makefile
@@ -10,6 +10,8 @@ fix:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
php $(HERE)/vendor/bin/php-cs-fixer fix --config=$(HERE)/.php_cs --dry-run
|
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:
|
test:
|
||||||
php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml
|
php $(HERE)/vendor/bin/phpunit --configuration $(HERE)/phpunit.xml
|
||||||
|
|||||||
@@ -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", [
|
$this->addConfigurationOption("minification", [
|
||||||
'html' => $this->getBoolAsOnOrOff($html),
|
'html' => $this->getBoolAsOnOrOff($html),
|
||||||
'css' => $this->getBoolAsOnOrOff($css),
|
'css' => $this->getBoolAsOnOrOff($css),
|
||||||
'js' => $this->getBoolAsOnOrOff($js),
|
'js' => $this->getBoolAsOnOrOff($javascript),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,9 +297,9 @@ class PageRulesActions implements Configurations
|
|||||||
return $this->configs;
|
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);
|
array_push($this->configs, (object) $configuration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,17 @@ class DNS implements API
|
|||||||
$this->adapter = $adapter;
|
$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(
|
public function addRecord(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $type,
|
string $type,
|
||||||
|
|||||||
@@ -21,6 +21,16 @@ class PageRules implements API
|
|||||||
$this->adapter = $adapter;
|
$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(
|
public function createPageRule(
|
||||||
string $zoneID,
|
string $zoneID,
|
||||||
PageRulesTargets $target,
|
PageRulesTargets $target,
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class UARules implements API
|
|||||||
string $zoneID,
|
string $zoneID,
|
||||||
string $mode,
|
string $mode,
|
||||||
\Cloudflare\API\Configurations\Configurations $configuration,
|
\Cloudflare\API\Configurations\Configurations $configuration,
|
||||||
string $id = null,
|
string $ruleID = null,
|
||||||
string $description = null
|
string $description = null
|
||||||
): bool {
|
): bool {
|
||||||
$options = [
|
$options = [
|
||||||
@@ -51,8 +51,8 @@ class UARules implements API
|
|||||||
'configurations' => $configuration->getArray()
|
'configurations' => $configuration->getArray()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($id !== null) {
|
if ($ruleID !== null) {
|
||||||
$options['id'] = $id;
|
$options['id'] = $ruleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($description !== null) {
|
if ($description !== null) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ZoneLockdown implements API
|
|||||||
string $zoneID,
|
string $zoneID,
|
||||||
array $urls,
|
array $urls,
|
||||||
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
|
\Cloudflare\API\Configurations\ZoneLockdown $configuration,
|
||||||
string $id = null,
|
string $lockdownID = null,
|
||||||
string $description = null
|
string $description = null
|
||||||
): bool {
|
): bool {
|
||||||
$options = [
|
$options = [
|
||||||
@@ -51,8 +51,8 @@ class ZoneLockdown implements API
|
|||||||
'configurations' => $configuration->getArray()
|
'configurations' => $configuration->getArray()
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($id !== null) {
|
if ($lockdownID !== null) {
|
||||||
$options['id'] = $id;
|
$options['id'] = $lockdownID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($description !== null) {
|
if ($description !== null) {
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ class Zones implements API
|
|||||||
$this->adapter = $adapter;
|
$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
|
public function addZone(string $name, bool $jumpstart = false, string $organizationID = ''): \stdClass
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
|
|||||||
@@ -133,6 +133,6 @@ class GuzzleTest extends TestCase
|
|||||||
public function testNotFound()
|
public function testNotFound()
|
||||||
{
|
{
|
||||||
$this->expectException(\GuzzleHttp\Exception\RequestException::class);
|
$this->expectException(\GuzzleHttp\Exception\RequestException::class);
|
||||||
$response = $this->client->get('https://httpbin.org/status/404');
|
$this->client->get('https://httpbin.org/status/404');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ class PageRulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
$result = $pageRules->createPageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -60,8 +60,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$pr->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all');
|
$pageRules->listPageRules('023e105f4ecef8ad9ca31a8372d0c353', 'active', 'status', 'desc', 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetPageRuleDetails()
|
public function testGetPageRuleDetails()
|
||||||
@@ -78,8 +78,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$pr->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
$pageRules->getPageRuleDetails('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdatePageRule()
|
public function testUpdatePageRule()
|
||||||
@@ -106,8 +106,8 @@ class PageRulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
$result = $pageRules->updatePageRule('023e105f4ecef8ad9ca31a8372d0c353', $target, $action, true, 1);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
@@ -127,8 +127,8 @@ class PageRulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$pr = new \Cloudflare\API\Endpoints\PageRules($mock);
|
$pageRules = new \Cloudflare\API\Endpoints\PageRules($mock);
|
||||||
$result = $pr->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
$result = $pageRules->deletePageRule('023e105f4ecef8ad9ca31a8372d0c353', '9a7806061c88ada191ed06f989cc3dac');
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
* Time: 15:19
|
* Time: 15:19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Cloudflare\API\Endpoints\UARules;
|
|
||||||
|
|
||||||
class UARulesTest extends TestCase
|
class UARulesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testListRules()
|
public function testListRules()
|
||||||
@@ -61,8 +59,8 @@ class UARulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->createRule(
|
$rules->createRule(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'js_challenge',
|
'js_challenge',
|
||||||
$config,
|
$config,
|
||||||
@@ -114,8 +112,8 @@ class UARulesTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->updateRule(
|
$rules->updateRule(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
'js_challenge',
|
'js_challenge',
|
||||||
@@ -139,7 +137,7 @@ class UARulesTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\UARules($mock);
|
$rules = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||||
$ld->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
$rules->deleteRule('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ class ZoneLockdownTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->createLockdown(
|
$zoneLockdown->createLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
["api.mysite.com/some/endpoint*"],
|
["api.mysite.com/some/endpoint*"],
|
||||||
$config,
|
$config,
|
||||||
@@ -112,8 +112,8 @@ class ZoneLockdownTest extends TestCase
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->updateLockdown(
|
$zoneLockdown->updateLockdown(
|
||||||
'023e105f4ecef8ad9ca31a8372d0c353',
|
'023e105f4ecef8ad9ca31a8372d0c353',
|
||||||
'372e67954025e0ba6aaa6d586b9e0b59',
|
'372e67954025e0ba6aaa6d586b9e0b59',
|
||||||
["api.mysite.com/some/endpoint*"],
|
["api.mysite.com/some/endpoint*"],
|
||||||
@@ -140,7 +140,7 @@ class ZoneLockdownTest extends TestCase
|
|||||||
$this->equalTo([])
|
$this->equalTo([])
|
||||||
);
|
);
|
||||||
|
|
||||||
$ld = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
$zoneLockdown = new \Cloudflare\API\Endpoints\ZoneLockdown($mock);
|
||||||
$ld->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
$zoneLockdown->deleteLockdown('023e105f4ecef8ad9ca31a8372d0c353', '372e67954025e0ba6aaa6d586b9e0b59');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user