Replaced CLRF by LF and cleaned files

This commit is contained in:
Francis Besset 2011-10-09 19:41:56 +02:00
parent cd2d8d90e8
commit b270a51ba5
3 changed files with 302 additions and 302 deletions

View File

@ -1,29 +1,29 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapServer. * This file is part of the BeSimpleSoapServer.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
*/ */
namespace BeSimple\SoapServer; namespace BeSimple\SoapServer;
/** /**
* @author Christian Kerl * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapServer extends \SoapServer class SoapServer extends \SoapServer
{ {
public function __construct($wsdl, array $options = array()) public function __construct($wsdl, array $options = array())
{ {
parent::__construct($wsdl, $options); parent::__construct($wsdl, $options);
} }
public function handle($soap_request = null) public function handle($soap_request = null)
{ {
parent::handle($soap_request); parent::handle($soap_request);
} }
} }

View File

@ -1,229 +1,229 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapServer. * This file is part of the BeSimpleSoapServer.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
*/ */
namespace BeSimple\SoapServer; namespace BeSimple\SoapServer;
use BeSimple\SoapCommon\AbstractSoapBuilder; use BeSimple\SoapCommon\AbstractSoapBuilder;
use BeSimple\SoapCommon\Converter\TypeConverterInterface; use BeSimple\SoapCommon\Converter\TypeConverterInterface;
use BeSimple\SoapCommon\Converter\TypeConverterCollection; use BeSimple\SoapCommon\Converter\TypeConverterCollection;
/** /**
* SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance. * SoapServerBuilder provides a fluent interface to configure and create a SoapServer instance.
* *
* @author Christian Kerl <christian-kerl@web.de> * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapServerBuilder extends AbstractSoapBuilder class SoapServerBuilder extends AbstractSoapBuilder
{ {
protected $persistence; protected $persistence;
protected $errorReporting; protected $errorReporting;
protected $handlerClass; protected $handlerClass;
protected $handlerObject; protected $handlerObject;
/** /**
* @return SoapServerBuilder * @return SoapServerBuilder
*/ */
static public function createWithDefaults() static public function createWithDefaults()
{ {
return parent::createWithDefaults() return parent::createWithDefaults()
->withErrorReporting(false) ->withErrorReporting(false)
; ;
} }
/** /**
* Initializes all options with the defaults used in the native SoapServer. * Initializes all options with the defaults used in the native SoapServer.
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->persistence = SOAP_PERSISTENCE_REQUEST; $this->persistence = SOAP_PERSISTENCE_REQUEST;
// TODO: this is not the default, but safer // TODO: this is not the default, but safer
$this->withErrorReporting(false); $this->withErrorReporting(false);
$this->options['classmap'] = array(); $this->options['classmap'] = array();
$this->options['typemap'] = array(); $this->options['typemap'] = array();
} }
public function build() public function build()
{ {
$this->validateOptions(); $this->validateOptions();
use_soap_error_handler($this->errorReporting); use_soap_error_handler($this->errorReporting);
$server = new SoapServer($this->wsdl, $this->options); $server = new SoapServer($this->wsdl, $this->options);
$server->setPersistence($this->persistence); $server->setPersistence($this->persistence);
if (null !== $this->handlerClass) { if (null !== $this->handlerClass) {
$server->setClass($this->handlerClass); $server->setClass($this->handlerClass);
} elseif (null !== $this->handlerObject) { } elseif (null !== $this->handlerObject) {
$server->setObject($this->handlerObject); $server->setObject($this->handlerObject);
} }
return $server; return $server;
} }
public function withActor($actor) public function withActor($actor)
{ {
$this->options['actor'] = $actor; $this->options['actor'] = $actor;
return $this; return $this;
} }
/** /**
* Enables the HTTP session. The handler object is persisted between multiple requests in a session. * Enables the HTTP session. The handler object is persisted between multiple requests in a session.
*/ */
public function withHttpSession() public function withHttpSession()
{ {
$this->persistence = SOAP_PERSISTENCE_SESSION; $this->persistence = SOAP_PERSISTENCE_SESSION;
return $this; return $this;
} }
/** /**
* Enables reporting of internal errors to clients. This should only be enabled in development environments. * Enables reporting of internal errors to clients. This should only be enabled in development environments.
* *
* @param boolean $enable * @param boolean $enable
*/ */
public function withErrorReporting($enable = true) public function withErrorReporting($enable = true)
{ {
$this->errorReporting = $enable; $this->errorReporting = $enable;
return $this; return $this;
} }
public function withBase64Attachments() public function withBase64Attachments()
{ {
return $this; return $this;
} }
public function withSwaAttachments() public function withSwaAttachments()
{ {
return $this; return $this;
} }
public function withMtomAttachments() public function withMtomAttachments()
{ {
return $this; return $this;
} }
/** /**
* @param mixed $handler Can be either a class name or an object. * @param mixed $handler Can be either a class name or an object.
* *
* @return SoapServerBuilder * @return SoapServerBuilder
*/ */
public function withHandler($handler) public function withHandler($handler)
{ {
if (is_string($handler) && class_exists($handler)) { if (is_string($handler) && class_exists($handler)) {
$this->handlerClass = $handler; $this->handlerClass = $handler;
$this->handlerObject = null; $this->handlerObject = null;
} elseif (is_object($handler)) { } elseif (is_object($handler)) {
$this->handlerClass = null; $this->handlerClass = null;
$this->handlerObject = $handler; $this->handlerObject = $handler;
} else { } else {
throw new \InvalidArgumentException('The handler has to be a class name or an object'); throw new \InvalidArgumentException('The handler has to be a class name or an object');
} }
return $this; return $this;
} }
public function withTypeConverter(TypeConverterInterface $converter) public function withTypeConverter(TypeConverterInterface $converter)
{ {
$this->withTypeMapping($converter->getTypeNamespace(), $converter->getTypeName(), array($converter, 'convertXmlToPhp'), array($converter, 'convertPhpToXml')); $this->withTypeMapping($converter->getTypeNamespace(), $converter->getTypeName(), array($converter, 'convertXmlToPhp'), array($converter, 'convertPhpToXml'));
return $this; return $this;
} }
public function withTypeConverters(TypeConverterCollection $converters, $merge = true) public function withTypeConverters(TypeConverterCollection $converters, $merge = true)
{ {
$this->withTypemap($converters->getTypemap(), $merge); $this->withTypemap($converters->getTypemap(), $merge);
return $this; return $this;
} }
/** /**
* Adds a type mapping to the typemap. * Adds a type mapping to the typemap.
* *
* @param string $xmlNamespace * @param string $xmlNamespace
* @param string $xmlType * @param string $xmlType
* @param callable $fromXmlCallback * @param callable $fromXmlCallback
* @param callable $toXmlCallback * @param callable $toXmlCallback
*/ */
public function withTypeMapping($xmlNamespace, $xmlType, $fromXmlCallback, $toXmlCallback) public function withTypeMapping($xmlNamespace, $xmlType, $fromXmlCallback, $toXmlCallback)
{ {
$this->options['typemap'][] = array( $this->options['typemap'][] = array(
'type_ns' => $xmlNamespace, 'type_ns' => $xmlNamespace,
'type_name' => $xmlType, 'type_name' => $xmlType,
'from_xml' => $fromXmlCallback, 'from_xml' => $fromXmlCallback,
'to_xml' => $toXmlCallback 'to_xml' => $toXmlCallback
); );
return $this; return $this;
} }
/** /**
* Sets the typemap. * Sets the typemap.
* *
* @param array $typemap 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. * @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) public function withTypemap($typemap, $merge = true)
{ {
if ($merge) { if ($merge) {
$this->options['typemap'] = array_merge($this->options['typemap'], $typemap); $this->options['typemap'] = array_merge($this->options['typemap'], $typemap);
} else { } else {
$this->options['typemap'] = $typemap; $this->options['typemap'] = $typemap;
} }
return $this; return $this;
} }
/** /**
* Adds a class mapping to the classmap. * Adds a class mapping to the classmap.
* *
* @param string $xmlType * @param string $xmlType
* @param string $phpType * @param string $phpType
*/ */
public function withClassMapping($xmlType, $phpType) public function withClassMapping($xmlType, $phpType)
{ {
$this->options['classmap'][$xmlType] = $phpType; $this->options['classmap'][$xmlType] = $phpType;
return $this; return $this;
} }
/** /**
* Sets the classmap. * Sets the classmap.
* *
* @param array $classmap 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. * @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) public function withClassmap($classmap, $merge = true)
{ {
if ($merge) { if ($merge) {
$this->options['classmap'] = array_merge($this->options['classmap'], $classmap); $this->options['classmap'] = array_merge($this->options['classmap'], $classmap);
} else { } else {
$this->options['classmap'] = $classmap; $this->options['classmap'] = $classmap;
} }
return $this; return $this;
} }
protected function validateOptions() protected function validateOptions()
{ {
$this->validateWsdl(); $this->validateWsdl();
if (null === $this->handlerClass && null === $this->handlerObject) { if (null === $this->handlerClass && null === $this->handlerObject) {
throw new \InvalidArgumentException('The handler has to be configured!'); throw new \InvalidArgumentException('The handler has to be configured!');
} }
} }
} }

View File

@ -1,45 +1,45 @@
<?php <?php
/* /*
* This file is part of the BeSimpleSoapServer. * This file is part of the BeSimpleSoapServer.
* *
* (c) Christian Kerl <christian-kerl@web.de> * (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com> * (c) Francis Besset <francis.besset@gmail.com>
* *
* This source file is subject to the MIT license that is bundled * This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE. * with this source code in the file LICENSE.
*/ */
namespace BeSimple\Tests\SoapServer; namespace BeSimple\Tests\SoapServer;
use BeSimple\SoapServer\SoapServerBuilder; use BeSimple\SoapServer\SoapServerBuilder;
/** /**
* UnitTest for \BeSimple\SoapServer\SoapServerBuilder * UnitTest for \BeSimple\SoapServer\SoapServerBuilder
* *
* @author Christian Kerl * @author Christian Kerl <christian-kerl@web.de>
*/ */
class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase
{ {
public function testUnconfiguredWsdl() public function testUnconfiguredWsdl()
{ {
$builder = $this->getSoapServerBuilder(); $builder = $this->getSoapServerBuilder();
$this->setExpectedException('InvalidArgumentException'); $this->setExpectedException('InvalidArgumentException');
$builder->build(); $builder->build();
} }
public function testUnconfiguredHandler() public function testUnconfiguredHandler()
{ {
$builder = $this->getSoapServerBuilder(); $builder = $this->getSoapServerBuilder();
$builder->withWsdl('my.wsdl'); $builder->withWsdl('my.wsdl');
$this->setExpectedException('InvalidArgumentException'); $this->setExpectedException('InvalidArgumentException');
$builder->build(); $builder->build();
} }
public function getSoapServerBuilder() public function getSoapServerBuilder()
{ {
return new SoapServerBuilder(); return new SoapServerBuilder();
} }
} }