Skip to content

Commit 22d43da

Browse files
committed
centralnic/issues#3926: fix codestyle
1 parent ae64058 commit 22d43da

39 files changed

+642
-620
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.php_cs.cache

Net/EPP.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
class Net_EPP
44
{
5-
65
/**
76
* load a class by giving it's short name
87
* @return boolean
@@ -12,7 +11,7 @@ public static function autoload($class)
1211
$prefix = __CLASS__.'_';
1312

1413
if ($prefix == substr($class, 0, strlen($prefix))) {
15-
$basedir=dirname(dirname(__FILE__));
14+
$basedir = dirname(dirname(__FILE__));
1615
syslog(LOG_INFO, "class name is {$class} from dir {$basedir}");
1716

1817
$file = $basedir.'/'.str_replace('_', '/', $class).'.php';

Net/EPP/Frame.php

+25-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
abstract class Net_EPP_Frame extends DomDocument {
3+
/**
4+
* @package Net_EPP
5+
*/
6+
abstract class Net_EPP_Frame extends DomDocument
7+
{
8+
const EPP_URN = 'urn:ietf:params:xml:ns:epp-1.0';
9+
const SCHEMA_URI = 'http://www.w3.org/2001/XMLSchema-instance';
10+
const TEMPLATE = '<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"></epp>';
711

8-
const EPP_URN = 'urn:ietf:params:xml:ns:epp-1.0';
9-
const SCHEMA_URI = 'http://www.w3.org/2001/XMLSchema-instance';
10-
const TEMPLATE = '<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"></epp>';
12+
public function __construct($type)
13+
{
14+
parent::__construct('1.0', 'UTF-8');
1115

12-
function __construct($type) {
13-
parent::__construct('1.0', 'UTF-8');
16+
$this->loadXML(self::TEMPLATE);
1417

15-
$this->loadXML(self::TEMPLATE);
18+
$type = strtolower($type);
19+
if (!in_array($type, array('hello', 'greeting', 'command', 'response'))) {
20+
trigger_error("Invalid argument value '$type' for \$type", E_USER_ERROR);
21+
}
1622

17-
$type = strtolower($type);
18-
if (!in_array($type, array('hello', 'greeting', 'command', 'response'))) trigger_error("Invalid argument value '$type' for \$type", E_USER_ERROR);
23+
$this->epp = $this->firstChild;
24+
$this->body = $this->createElement($type);
25+
$this->epp->appendChild($this->body);
26+
}
1927

20-
$this->epp = $this->firstChild;
21-
$this->body = $this->createElement($type);
22-
$this->epp->appendChild($this->body);
23-
}
24-
25-
function friendly() {
26-
return str_replace('><', ">\n<", $this->saveXML());
27-
}
28-
}
29-
?>
28+
public function friendly()
29+
{
30+
return str_replace('><', ">\n<", $this->saveXML());
31+
}
32+
}

Net/EPP/Frame/Command.php

+65-60
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,80 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command extends Net_EPP_Frame {
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command extends Net_EPP_Frame
7+
{
8+
public function __construct($command, $type = "")
9+
{
10+
$this->type = $type;
11+
$command = strtolower($command);
12+
if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) {
13+
trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR);
14+
}
15+
parent::__construct('command');
716

8-
function __construct($command, $type="") {
9-
$this->type = $type;
10-
$command = strtolower($command);
11-
if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR);
12-
parent::__construct('command');
17+
$this->command = $this->createElement($command);
18+
$this->body->appendChild($this->command);
1319

14-
$this->command = $this->createElement($command);
15-
$this->body->appendChild($this->command);
20+
if (!empty($this->type)) {
21+
$this->payload = $this->createElementNS(
22+
Net_EPP_ObjectSpec::xmlns($this->type),
23+
$this->type.':'.$command
24+
);
1625

17-
if (!empty($this->type)) {
18-
$this->payload = $this->createElementNS(
19-
Net_EPP_ObjectSpec::xmlns($this->type),
20-
$this->type.':'.$command
21-
);
26+
$this->command->appendChild($this->payload);
27+
}
28+
}
2229

23-
$this->command->appendChild($this->payload);
24-
}
25-
}
30+
public function addclTRID($id)
31+
{
32+
$this->clTRID = $this->createElement('clTRID');
33+
$this->clTRID->appendChild($this->createTextNode($id));
34+
$this->body->appendChild($this->clTRID);
35+
}
2636

27-
function addclTRID($id) {
28-
$this->clTRID = $this->createElement('clTRID');
29-
$this->clTRID->appendChild($this->createTextNode($id));
30-
$this->body->appendChild($this->clTRID);
31-
}
37+
public function addObjectProperty($name, $value = null)
38+
{
39+
$element = $this->createObjectPropertyElement($name);
40+
$this->payload->appendChild($element);
3241

33-
function addObjectProperty($name, $value=NULL) {
34-
$element = $this->createObjectPropertyElement($name);
35-
$this->payload->appendChild($element);
42+
if ($value instanceof DomNode) {
43+
$element->appendChild($value);
44+
} elseif (isset($value)) {
45+
$element->appendChild($this->createTextNode($value));
46+
}
47+
return $element;
48+
}
3649

37-
if ($value instanceof DomNode) {
38-
$element->appendChild($value);
50+
public function createObjectPropertyElement($name, $type = null)
51+
{
52+
$ns_type = isset($type) ? $type : $this->type;
53+
$ns = !empty($ns_type) ? $ns_type.':'.$name : $name;
54+
return $this->createElementNS(
55+
Net_EPP_ObjectSpec::xmlns($ns_type),
56+
$ns
57+
);
58+
}
3959

40-
} elseif (isset($value)) {
41-
$element->appendChild($this->createTextNode($value));
42-
43-
}
44-
return $element;
45-
}
46-
47-
function createObjectPropertyElement($name, $type=NULL) {
48-
$ns_type = isset($type) ? $type : $this->type;
49-
$ns = !empty($ns_type) ? $ns_type.':'.$name : $name;
50-
return $this->createElementNS(
51-
Net_EPP_ObjectSpec::xmlns($ns_type), $ns
52-
);
53-
}
54-
55-
function createExtension() {
56-
$this->extension = $this->createElement('extension');
57-
$this->body->appendChild($this->extension);
58-
}
60+
public function createExtension()
61+
{
62+
$this->extension = $this->createElement('extension');
63+
$this->body->appendChild($this->extension);
64+
}
5965

6066
/**
61-
* Creates an extension element with the option of specifying a custom namespace
67+
* Creates an extension element with the option of specifying a custom namespace
6268
* @param $ext
6369
* @param $command
64-
* @param null $version *
70+
* @param null $version *
6571
*/
66-
function createExtensionElement($ext, $command, $version=null) {
67-
$this->extension->payload = $this->createElementNS(
68-
Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext),
69-
$ext.':'.$command
70-
);
71-
$this->extension->appendChild($this->extension->payload);
72-
}
73-
74-
}
75-
?>
72+
public function createExtensionElement($ext, $command, $version = null)
73+
{
74+
$this->extension->payload = $this->createElementNS(
75+
Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext),
76+
$ext.':'.$command
77+
);
78+
$this->extension->appendChild($this->extension->payload);
79+
}
80+
}

Net/EPP/Frame/Command/Check.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
abstract class Net_EPP_Frame_Command_Check extends Net_EPP_Frame_Command {
3+
/**
4+
* @package Net_EPP
5+
*/
6+
abstract class Net_EPP_Frame_Command_Check extends Net_EPP_Frame_Command
7+
{
8+
public function __construct($type)
9+
{
10+
parent::__construct('check', $type);
11+
}
712

8-
function __construct($type) {
9-
parent::__construct('check', $type);
10-
}
11-
12-
function addObject($object) {
13-
$type = strtolower(str_replace(__CLASS__.'_', '', get_class($this)));
14-
$this->payload->appendChild($this->createElementNS(
15-
Net_EPP_ObjectSpec::xmlns($type),
16-
$type.':'.Net_EPP_ObjectSpec::id($type),
17-
$object
18-
));
19-
}
20-
21-
}
22-
?>
13+
public function addObject($object)
14+
{
15+
$type = strtolower(str_replace(__CLASS__.'_', '', get_class($this)));
16+
$this->payload->appendChild($this->createElementNS(
17+
Net_EPP_ObjectSpec::xmlns($type),
18+
$type.':'.Net_EPP_ObjectSpec::id($type),
19+
$object
20+
));
21+
}
22+
}
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Check_Contact extends Net_EPP_Frame_Command_Check {
7-
8-
function __construct() {
9-
parent::__construct('contact');
10-
}
11-
}
12-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Check_Contact extends Net_EPP_Frame_Command_Check
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct('contact');
11+
}
12+
}
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Check_Domain extends Net_EPP_Frame_Command_Check {
7-
8-
function __construct() {
9-
parent::__construct('domain');
10-
}
11-
}
12-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Check_Domain extends Net_EPP_Frame_Command_Check
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct('domain');
11+
}
12+
}

Net/EPP/Frame/Command/Check/Host.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Check_Host extends Net_EPP_Frame_Command_Check {
7-
8-
function __construct() {
9-
parent::__construct('host');
10-
}
11-
}
12-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Check_Host extends Net_EPP_Frame_Command_Check
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct('host');
11+
}
12+
}

Net/EPP/Frame/Command/Create.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Create extends Net_EPP_Frame_Command {
7-
8-
function __construct($type) {
9-
$this->type = $type;
10-
parent::__construct('create', $type);
11-
}
12-
}
13-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Create extends Net_EPP_Frame_Command
7+
{
8+
public function __construct($type)
9+
{
10+
$this->type = $type;
11+
parent::__construct('create', $type);
12+
}
13+
}
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Create_Contact extends Net_EPP_Frame_Command_Create {
7-
8-
function __construct() {
9-
parent::__construct('contact');
10-
}
11-
}
12-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Create_Contact extends Net_EPP_Frame_Command_Create
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct('contact');
11+
}
12+
}
+10-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22

3-
/**
4-
* @package Net_EPP
5-
*/
6-
class Net_EPP_Frame_Command_Create_Domain extends Net_EPP_Frame_Command_Create {
7-
8-
function __construct() {
9-
parent::__construct('domain');
10-
}
11-
12-
}
13-
?>
3+
/**
4+
* @package Net_EPP
5+
*/
6+
class Net_EPP_Frame_Command_Create_Domain extends Net_EPP_Frame_Command_Create
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct('domain');
11+
}
12+
}

0 commit comments

Comments
 (0)