Skip to content

Commit b67fef6

Browse files
committed
Cleanup.
1 parent 1eb7aa3 commit b67fef6

File tree

2 files changed

+71
-31
lines changed

2 files changed

+71
-31
lines changed

src/WSDL/Parser/ClassParser.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,42 @@
3434
*/
3535
class ClassParser
3636
{
37-
private $_reflectedClass;
37+
/**
38+
* @var ReflectionClass
39+
*/
40+
private $reflectedClass;
3841
/**
3942
* @var MethodParser[]
4043
*/
41-
private $_methodDocComments = array();
44+
private $methodDocComments = array();
4245

4346
public function __construct($className)
4447
{
45-
$this->_reflectedClass = new ReflectionClass($className);
48+
$this->reflectedClass = new ReflectionClass($className);
4649
}
4750

4851
public function parse()
4952
{
50-
$this->_getAllPublicMethodDocComment();
53+
$this->allPublicMethodDocComment();
5154
}
5255

53-
private function _getAllPublicMethodDocComment()
56+
private function allPublicMethodDocComment()
5457
{
55-
$reflectionClassMethods = $this->_reflectedClass->getMethods();
56-
foreach ($reflectionClassMethods as $method) {
57-
if ($this->_checkCanParseMethod($method)) {
58-
$methodName = $method->getName();
59-
$methodDocComment = $method->getDocComment();
60-
$this->_methodDocComments[] = new MethodParser($methodName, $methodDocComment);
58+
$reflectionClassMethods = $this->reflectedClass->getMethods();
59+
foreach ($reflectionClassMethods as $reflectionMethod) {
60+
if ($this->canParseMethod($reflectionMethod)) {
61+
$methodName = $reflectionMethod->getName();
62+
$methodDocComment = $reflectionMethod->getDocComment();
63+
$this->methodDocComments[] = new MethodParser($methodName, $methodDocComment);
6164
}
6265
}
63-
return $this;
6466
}
6567

66-
private function _checkCanParseMethod(ReflectionMethod $method)
68+
/**
69+
* @param ReflectionMethod $method
70+
* @return bool
71+
*/
72+
private function canParseMethod(ReflectionMethod $method)
6773
{
6874
return
6975
Strings::contains($method->getDocComment(), '@WebMethod') &&
@@ -73,8 +79,11 @@ private function _checkCanParseMethod(ReflectionMethod $method)
7379
!Strings::contains($method->getName(), '__');
7480
}
7581

82+
/**
83+
* @return MethodParser[]
84+
*/
7685
public function getMethods()
7786
{
78-
return $this->_methodDocComments;
87+
return $this->methodDocComments;
7988
}
8089
}

src/WSDL/Parser/MethodParser.php

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
namespace WSDL\Parser;
2525

2626
use Ouzo\Utilities\Arrays;
27+
use Ouzo\Utilities\Functions;
2728
use WSDL\Types\Type;
2829

2930
/**
@@ -33,21 +34,36 @@
3334
*/
3435
class MethodParser
3536
{
36-
private $_name;
37-
private $_doc;
38-
private $_rawParameters;
39-
private $_rawReturn;
37+
/**
38+
* @var string
39+
*/
40+
private $name;
41+
/**
42+
* @var string
43+
*/
44+
private $doc;
45+
/**
46+
* @var array
47+
*/
48+
private $rawParameters;
49+
/**
50+
* @var string
51+
*/
52+
private $rawReturn;
4053

4154
public function __construct($name, $doc)
4255
{
43-
$this->_name = $name;
44-
$this->_doc = $doc;
56+
$this->name = $name;
57+
$this->doc = $doc;
4558
}
4659

60+
/**
61+
* @return string
62+
*/
4763
public function description()
4864
{
49-
preg_match('#@desc (.+)#', $this->_doc, $groupMatches);
50-
$trimGroupMatches = array_map('trim', $groupMatches);
65+
preg_match('#@desc (.+)#', $this->doc, $groupMatches);
66+
$trimGroupMatches = Arrays::map($groupMatches, Functions::trim());
5167
return Arrays::getValue($trimGroupMatches, 1, '');
5268
}
5369

@@ -56,41 +72,56 @@ public function description()
5672
*/
5773
public function parameters()
5874
{
59-
preg_match_all('#@param (.+)#', $this->_doc, $groupMatches);
60-
$this->_rawParameters = $groupMatches[1];
75+
preg_match_all('#@param (.+)#', $this->doc, $groupMatches);
76+
$this->rawParameters = $groupMatches[1];
6177
return ParameterParser::create($groupMatches[1], $this->getName());
6278
}
6379

80+
/**
81+
* @return Type
82+
*/
6483
public function returning()
6584
{
66-
preg_match('#@return (.+)#', $this->_doc, $groupMatches);
85+
preg_match('#@return (.+)#', $this->doc, $groupMatches);
6786
$trimGroupMatches = array_map('trim', $groupMatches);
6887
if (isset($trimGroupMatches[1])) {
69-
$this->_rawReturn = $trimGroupMatches[1];
88+
$this->rawReturn = $trimGroupMatches[1];
7089
}
71-
$parameterParser = new ParameterParser($this->_rawReturn, $this->getName());
90+
$parameterParser = new ParameterParser($this->rawReturn, $this->getName());
7291
return $parameterParser->parse();
7392
}
7493

94+
/**
95+
* @return string
96+
*/
7597
public function getDoc()
7698
{
77-
return $this->_doc;
99+
return $this->doc;
78100
}
79101

102+
/**
103+
* @return string
104+
*/
80105
public function getName()
81106
{
82-
return $this->_name;
107+
return $this->name;
83108
}
84109

110+
/**
111+
* @return array
112+
*/
85113
public function getRawParameters()
86114
{
87115
$this->parameters();
88-
return $this->_rawParameters;
116+
return $this->rawParameters;
89117
}
90118

119+
/**
120+
* @return string
121+
*/
91122
public function getRawReturn()
92123
{
93124
$this->returning();
94-
return $this->_rawReturn;
125+
return $this->rawReturn;
95126
}
96127
}

0 commit comments

Comments
 (0)