diff --git a/src/WSDL/Parser/ClassParser.php b/src/WSDL/Parser/ClassParser.php index a1e04f6..9974308 100644 --- a/src/WSDL/Parser/ClassParser.php +++ b/src/WSDL/Parser/ClassParser.php @@ -34,36 +34,42 @@ */ class ClassParser { - private $_reflectedClass; + /** + * @var ReflectionClass + */ + private $reflectedClass; /** * @var MethodParser[] */ - private $_methodDocComments = array(); + private $methodDocComments = array(); public function __construct($className) { - $this->_reflectedClass = new ReflectionClass($className); + $this->reflectedClass = new ReflectionClass($className); } public function parse() { - $this->_getAllPublicMethodDocComment(); + $this->allPublicMethodDocComment(); } - private function _getAllPublicMethodDocComment() + private function allPublicMethodDocComment() { - $reflectionClassMethods = $this->_reflectedClass->getMethods(); - foreach ($reflectionClassMethods as $method) { - if ($this->_checkCanParseMethod($method)) { - $methodName = $method->getName(); - $methodDocComment = $method->getDocComment(); - $this->_methodDocComments[] = new MethodParser($methodName, $methodDocComment); + $reflectionClassMethods = $this->reflectedClass->getMethods(); + foreach ($reflectionClassMethods as $reflectionMethod) { + if ($this->canParseMethod($reflectionMethod)) { + $methodName = $reflectionMethod->getName(); + $methodDocComment = $reflectionMethod->getDocComment(); + $this->methodDocComments[] = new MethodParser($methodName, $methodDocComment); } } - return $this; } - private function _checkCanParseMethod(ReflectionMethod $method) + /** + * @param ReflectionMethod $method + * @return bool + */ + private function canParseMethod(ReflectionMethod $method) { return Strings::contains($method->getDocComment(), '@WebMethod') && @@ -73,8 +79,11 @@ private function _checkCanParseMethod(ReflectionMethod $method) !Strings::contains($method->getName(), '__'); } + /** + * @return MethodParser[] + */ public function getMethods() { - return $this->_methodDocComments; + return $this->methodDocComments; } } diff --git a/src/WSDL/Parser/MethodParser.php b/src/WSDL/Parser/MethodParser.php index 9189e81..620baca 100644 --- a/src/WSDL/Parser/MethodParser.php +++ b/src/WSDL/Parser/MethodParser.php @@ -24,6 +24,7 @@ namespace WSDL\Parser; use Ouzo\Utilities\Arrays; +use Ouzo\Utilities\Functions; use WSDL\Types\Type; /** @@ -33,21 +34,36 @@ */ class MethodParser { - private $_name; - private $_doc; - private $_rawParameters; - private $_rawReturn; + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $doc; + /** + * @var array + */ + private $rawParameters; + /** + * @var string + */ + private $rawReturn; public function __construct($name, $doc) { - $this->_name = $name; - $this->_doc = $doc; + $this->name = $name; + $this->doc = $doc; } + /** + * @return string + */ public function description() { - preg_match('#@desc (.+)#', $this->_doc, $groupMatches); - $trimGroupMatches = array_map('trim', $groupMatches); + preg_match('#@desc (.+)#', $this->doc, $groupMatches); + $trimGroupMatches = Arrays::map($groupMatches, Functions::trim()); return Arrays::getValue($trimGroupMatches, 1, ''); } @@ -56,41 +72,56 @@ public function description() */ public function parameters() { - preg_match_all('#@param (.+)#', $this->_doc, $groupMatches); - $this->_rawParameters = $groupMatches[1]; + preg_match_all('#@param (.+)#', $this->doc, $groupMatches); + $this->rawParameters = $groupMatches[1]; return ParameterParser::create($groupMatches[1], $this->getName()); } + /** + * @return Type + */ public function returning() { - preg_match('#@return (.+)#', $this->_doc, $groupMatches); + preg_match('#@return (.+)#', $this->doc, $groupMatches); $trimGroupMatches = array_map('trim', $groupMatches); if (isset($trimGroupMatches[1])) { - $this->_rawReturn = $trimGroupMatches[1]; + $this->rawReturn = $trimGroupMatches[1]; } - $parameterParser = new ParameterParser($this->_rawReturn, $this->getName()); + $parameterParser = new ParameterParser($this->rawReturn, $this->getName()); return $parameterParser->parse(); } + /** + * @return string + */ public function getDoc() { - return $this->_doc; + return $this->doc; } + /** + * @return string + */ public function getName() { - return $this->_name; + return $this->name; } + /** + * @return array + */ public function getRawParameters() { $this->parameters(); - return $this->_rawParameters; + return $this->rawParameters; } + /** + * @return string + */ public function getRawReturn() { $this->returning(); - return $this->_rawReturn; + return $this->rawReturn; } }