From b270a51ba5f6a14367dfaa079d5273ea2228eea1 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 9 Oct 2011 19:41:56 +0200 Subject: [PATCH] Replaced CLRF by LF and cleaned files --- src/BeSimple/SoapServer/SoapServer.php | 58 +-- src/BeSimple/SoapServer/SoapServerBuilder.php | 458 +++++++++--------- .../SoapServer/SoapServerBuilderTest.php | 88 ++-- 3 files changed, 302 insertions(+), 302 deletions(-) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 346a998..afc044c 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -1,29 +1,29 @@ - - * (c) Francis Besset - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace BeSimple\SoapServer; - -/** - * @author Christian Kerl - */ -class SoapServer extends \SoapServer -{ - public function __construct($wsdl, array $options = array()) - { - parent::__construct($wsdl, $options); - } - - public function handle($soap_request = null) - { - parent::handle($soap_request); - } -} + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapServer; + +/** + * @author Christian Kerl + */ +class SoapServer extends \SoapServer +{ + public function __construct($wsdl, array $options = array()) + { + parent::__construct($wsdl, $options); + } + + public function handle($soap_request = null) + { + parent::handle($soap_request); + } +} \ No newline at end of file diff --git a/src/BeSimple/SoapServer/SoapServerBuilder.php b/src/BeSimple/SoapServer/SoapServerBuilder.php index ef80505..0b192f9 100644 --- a/src/BeSimple/SoapServer/SoapServerBuilder.php +++ b/src/BeSimple/SoapServer/SoapServerBuilder.php @@ -1,229 +1,229 @@ - - * (c) Francis Besset - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace BeSimple\SoapServer; - -use BeSimple\SoapCommon\AbstractSoapBuilder; -use BeSimple\SoapCommon\Converter\TypeConverterInterface; -use BeSimple\SoapCommon\Converter\TypeConverterCollection; - -/** - * SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance. - * - * @author Christian Kerl - */ -class SoapServerBuilder extends AbstractSoapBuilder -{ - protected $persistence; - protected $errorReporting; - - protected $handlerClass; - protected $handlerObject; - - /** - * @return SoapServerBuilder - */ - static public function createWithDefaults() - { - return parent::createWithDefaults() - ->withErrorReporting(false) - ; - } - - /** - * Initializes all options with the defaults used in the native SoapServer. - */ - public function __construct() - { - parent::__construct(); - - $this->persistence = SOAP_PERSISTENCE_REQUEST; - - // TODO: this is not the default, but safer - $this->withErrorReporting(false); - - $this->options['classmap'] = array(); - $this->options['typemap'] = array(); - } - - public function build() - { - $this->validateOptions(); - - use_soap_error_handler($this->errorReporting); - - $server = new SoapServer($this->wsdl, $this->options); - $server->setPersistence($this->persistence); - - if (null !== $this->handlerClass) { - $server->setClass($this->handlerClass); - } elseif (null !== $this->handlerObject) { - $server->setObject($this->handlerObject); - } - - return $server; - } - - public function withActor($actor) - { - $this->options['actor'] = $actor; - - return $this; - } - - /** - * Enables the HTTP session. The handler object is persisted between multiple requests in a session. - */ - public function withHttpSession() - { - $this->persistence = SOAP_PERSISTENCE_SESSION; - - return $this; - } - - /** - * Enables reporting of internal errors to clients. This should only be enabled in development environments. - * - * @param boolean $enable - */ - public function withErrorReporting($enable = true) - { - $this->errorReporting = $enable; - - return $this; - } - - public function withBase64Attachments() - { - return $this; - } - - public function withSwaAttachments() - { - return $this; - } - - public function withMtomAttachments() - { - return $this; - } - - /** - * @param mixed $handler Can be either a class name or an object. - * - * @return SoapServerBuilder - */ - public function withHandler($handler) - { - if (is_string($handler) && class_exists($handler)) { - $this->handlerClass = $handler; - $this->handlerObject = null; - } elseif (is_object($handler)) { - $this->handlerClass = null; - $this->handlerObject = $handler; - } else { - throw new \InvalidArgumentException('The handler has to be a class name or an object'); - } - - return $this; - } - - public function withTypeConverter(TypeConverterInterface $converter) - { - $this->withTypeMapping($converter->getTypeNamespace(), $converter->getTypeName(), array($converter, 'convertXmlToPhp'), array($converter, 'convertPhpToXml')); - - return $this; - } - - public function withTypeConverters(TypeConverterCollection $converters, $merge = true) - { - $this->withTypemap($converters->getTypemap(), $merge); - - return $this; - } - - /** - * Adds a type mapping to the typemap. - * - * @param string $xmlNamespace - * @param string $xmlType - * @param callable $fromXmlCallback - * @param callable $toXmlCallback - */ - public function withTypeMapping($xmlNamespace, $xmlType, $fromXmlCallback, $toXmlCallback) - { - $this->options['typemap'][] = array( - 'type_ns' => $xmlNamespace, - 'type_name' => $xmlType, - 'from_xml' => $fromXmlCallback, - 'to_xml' => $toXmlCallback - ); - - return $this; - } - - /** - * Sets the typemap. - * - * @param array $typemap The typemap. - * @param boolean $merge If true the given typemap is merged into the existing one, otherwise the existing one is overwritten. - */ - public function withTypemap($typemap, $merge = true) - { - if ($merge) { - $this->options['typemap'] = array_merge($this->options['typemap'], $typemap); - } else { - $this->options['typemap'] = $typemap; - } - - return $this; - } - - /** - * Adds a class mapping to the classmap. - * - * @param string $xmlType - * @param string $phpType - */ - public function withClassMapping($xmlType, $phpType) - { - $this->options['classmap'][$xmlType] = $phpType; - - return $this; - } - - /** - * Sets the classmap. - * - * @param array $classmap The classmap. - * @param boolean $merge If true the given classmap is merged into the existing one, otherwise the existing one is overwritten. - */ - public function withClassmap($classmap, $merge = true) - { - if ($merge) { - $this->options['classmap'] = array_merge($this->options['classmap'], $classmap); - } else { - $this->options['classmap'] = $classmap; - } - - return $this; - } - - protected function validateOptions() - { - $this->validateWsdl(); - - if (null === $this->handlerClass && null === $this->handlerObject) { - throw new \InvalidArgumentException('The handler has to be configured!'); - } - } -} + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapServer; + +use BeSimple\SoapCommon\AbstractSoapBuilder; +use BeSimple\SoapCommon\Converter\TypeConverterInterface; +use BeSimple\SoapCommon\Converter\TypeConverterCollection; + +/** + * SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance. + * + * @author Christian Kerl + */ +class SoapServerBuilder extends AbstractSoapBuilder +{ + protected $persistence; + protected $errorReporting; + + protected $handlerClass; + protected $handlerObject; + + /** + * @return SoapServerBuilder + */ + static public function createWithDefaults() + { + return parent::createWithDefaults() + ->withErrorReporting(false) + ; + } + + /** + * Initializes all options with the defaults used in the native SoapServer. + */ + public function __construct() + { + parent::__construct(); + + $this->persistence = SOAP_PERSISTENCE_REQUEST; + + // TODO: this is not the default, but safer + $this->withErrorReporting(false); + + $this->options['classmap'] = array(); + $this->options['typemap'] = array(); + } + + public function build() + { + $this->validateOptions(); + + use_soap_error_handler($this->errorReporting); + + $server = new SoapServer($this->wsdl, $this->options); + $server->setPersistence($this->persistence); + + if (null !== $this->handlerClass) { + $server->setClass($this->handlerClass); + } elseif (null !== $this->handlerObject) { + $server->setObject($this->handlerObject); + } + + return $server; + } + + public function withActor($actor) + { + $this->options['actor'] = $actor; + + return $this; + } + + /** + * Enables the HTTP session. The handler object is persisted between multiple requests in a session. + */ + public function withHttpSession() + { + $this->persistence = SOAP_PERSISTENCE_SESSION; + + return $this; + } + + /** + * Enables reporting of internal errors to clients. This should only be enabled in development environments. + * + * @param boolean $enable + */ + public function withErrorReporting($enable = true) + { + $this->errorReporting = $enable; + + return $this; + } + + public function withBase64Attachments() + { + return $this; + } + + public function withSwaAttachments() + { + return $this; + } + + public function withMtomAttachments() + { + return $this; + } + + /** + * @param mixed $handler Can be either a class name or an object. + * + * @return SoapServerBuilder + */ + public function withHandler($handler) + { + if (is_string($handler) && class_exists($handler)) { + $this->handlerClass = $handler; + $this->handlerObject = null; + } elseif (is_object($handler)) { + $this->handlerClass = null; + $this->handlerObject = $handler; + } else { + throw new \InvalidArgumentException('The handler has to be a class name or an object'); + } + + return $this; + } + + public function withTypeConverter(TypeConverterInterface $converter) + { + $this->withTypeMapping($converter->getTypeNamespace(), $converter->getTypeName(), array($converter, 'convertXmlToPhp'), array($converter, 'convertPhpToXml')); + + return $this; + } + + public function withTypeConverters(TypeConverterCollection $converters, $merge = true) + { + $this->withTypemap($converters->getTypemap(), $merge); + + return $this; + } + + /** + * Adds a type mapping to the typemap. + * + * @param string $xmlNamespace + * @param string $xmlType + * @param callable $fromXmlCallback + * @param callable $toXmlCallback + */ + public function withTypeMapping($xmlNamespace, $xmlType, $fromXmlCallback, $toXmlCallback) + { + $this->options['typemap'][] = array( + 'type_ns' => $xmlNamespace, + 'type_name' => $xmlType, + 'from_xml' => $fromXmlCallback, + 'to_xml' => $toXmlCallback + ); + + return $this; + } + + /** + * Sets the typemap. + * + * @param array $typemap The typemap. + * @param boolean $merge If true the given typemap is merged into the existing one, otherwise the existing one is overwritten. + */ + public function withTypemap($typemap, $merge = true) + { + if ($merge) { + $this->options['typemap'] = array_merge($this->options['typemap'], $typemap); + } else { + $this->options['typemap'] = $typemap; + } + + return $this; + } + + /** + * Adds a class mapping to the classmap. + * + * @param string $xmlType + * @param string $phpType + */ + public function withClassMapping($xmlType, $phpType) + { + $this->options['classmap'][$xmlType] = $phpType; + + return $this; + } + + /** + * Sets the classmap. + * + * @param array $classmap The classmap. + * @param boolean $merge If true the given classmap is merged into the existing one, otherwise the existing one is overwritten. + */ + public function withClassmap($classmap, $merge = true) + { + if ($merge) { + $this->options['classmap'] = array_merge($this->options['classmap'], $classmap); + } else { + $this->options['classmap'] = $classmap; + } + + return $this; + } + + protected function validateOptions() + { + $this->validateWsdl(); + + if (null === $this->handlerClass && null === $this->handlerObject) { + throw new \InvalidArgumentException('The handler has to be configured!'); + } + } +} \ No newline at end of file diff --git a/tests/BeSimple/Tests/SoapServer/SoapServerBuilderTest.php b/tests/BeSimple/Tests/SoapServer/SoapServerBuilderTest.php index 71a3fde..df46d46 100644 --- a/tests/BeSimple/Tests/SoapServer/SoapServerBuilderTest.php +++ b/tests/BeSimple/Tests/SoapServer/SoapServerBuilderTest.php @@ -1,45 +1,45 @@ - - * (c) Francis Besset - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace BeSimple\Tests\SoapServer; - -use BeSimple\SoapServer\SoapServerBuilder; - -/** - * UnitTest for \BeSimple\SoapServer\SoapServerBuilder - * - * @author Christian Kerl - */ -class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase -{ - public function testUnconfiguredWsdl() - { - $builder = $this->getSoapServerBuilder(); - - $this->setExpectedException('InvalidArgumentException'); - $builder->build(); - } - - public function testUnconfiguredHandler() - { - $builder = $this->getSoapServerBuilder(); - $builder->withWsdl('my.wsdl'); - - $this->setExpectedException('InvalidArgumentException'); - $builder->build(); - } - - public function getSoapServerBuilder() - { - return new SoapServerBuilder(); - } + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\Tests\SoapServer; + +use BeSimple\SoapServer\SoapServerBuilder; + +/** + * UnitTest for \BeSimple\SoapServer\SoapServerBuilder + * + * @author Christian Kerl + */ +class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase +{ + public function testUnconfiguredWsdl() + { + $builder = $this->getSoapServerBuilder(); + + $this->setExpectedException('InvalidArgumentException'); + $builder->build(); + } + + public function testUnconfiguredHandler() + { + $builder = $this->getSoapServerBuilder(); + $builder->withWsdl('my.wsdl'); + + $this->setExpectedException('InvalidArgumentException'); + $builder->build(); + } + + public function getSoapServerBuilder() + { + return new SoapServerBuilder(); + } } \ No newline at end of file