BeSimpleSoap/ServiceDefinition/Loader/AnnotationReader.php

39 lines
1.1 KiB
PHP
Raw Normal View History

2011-04-09 00:40:31 +02:00
<?php
/*
* This file is part of the WebServiceBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Bundle\WebServiceBundle\ServiceDefinition\Loader;
use Doctrine\Common\Annotations\AnnotationReader as BaseAnnotationReader;
/**
* AnnotationReader.
*
* @author Christian Kerl <christian-kerl@web.de>
*/
class AnnotationReader extends BaseAnnotationReader
{
public function getMethodAnnotation(\ReflectionMethod $method, $type)
{
$annotation = parent::getMethodAnnotation($method, $type);
2011-07-14 17:45:03 +02:00
if($annotation !== null && count($annotation) > 1) {
2011-04-09 00:40:31 +02:00
throw new \LogicException(sprintf("There is more than one annotation of type '%s'!", $type));
}
2011-07-14 17:45:03 +02:00
2011-04-09 00:40:31 +02:00
return $annotation !== null ? $annotation[0] : null;
}
2011-07-14 17:45:03 +02:00
2011-04-09 00:40:31 +02:00
public function getMethodAnnotations(\ReflectionMethod $method, $type = null)
{
$annotations = parent::getMethodAnnotations($method);
2011-07-14 17:45:03 +02:00
2011-04-09 00:40:31 +02:00
return $type !== null && isset($annotations[$type]) ? $annotations[$type] : $annotations;
}
}