Added TypeConverterCollection
This commit is contained in:
parent
d0cc3e8bd2
commit
69d1e59edf
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the BeSimpleSoapCommon.
|
||||||
|
*
|
||||||
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
* (c) Francis Besset <francis.besset@gmail.com>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BeSimple\SoapCommon\Converter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
|
*/
|
||||||
|
class TypeConverterCollection
|
||||||
|
{
|
||||||
|
private $typeConverters = array();
|
||||||
|
|
||||||
|
public function add(TypeConverterInterface $converter)
|
||||||
|
{
|
||||||
|
$this->typeConverters[] = $converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function all()
|
||||||
|
{
|
||||||
|
return $this->typeConverters;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the BeSimpleSoapCommon.
|
||||||
|
*
|
||||||
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
* (c) Francis Besset <francis.besset@gmail.com>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BeSimple\SoapCommon\Converter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
|
*/
|
||||||
|
interface TypeConverterInterface
|
||||||
|
{
|
||||||
|
function getTypeNamespace();
|
||||||
|
|
||||||
|
function getTypeName();
|
||||||
|
|
||||||
|
function convertXmlToPhp($data);
|
||||||
|
|
||||||
|
function convertPhpToXml($data);
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the BeSimpleSoapCommon.
|
||||||
|
*
|
||||||
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
* (c) Francis Besset <francis.besset@gmail.com>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BeSimple\SoapCommon\Tests\Converter;
|
||||||
|
|
||||||
|
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
|
||||||
|
use BeSimple\SoapCommon\Converter\DateTimeTypeConverter;
|
||||||
|
use BeSimple\SoapCommon\Converter\DateTypeConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UnitTest for \BeSimple\SoapCommon\Converter\TypeConverterCollection.
|
||||||
|
*
|
||||||
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
|
*/
|
||||||
|
class TypeConverterCollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testAdd()
|
||||||
|
{
|
||||||
|
$converters = new TypeConverterCollection();
|
||||||
|
|
||||||
|
$dateTimeTypeConverter = new DateTimeTypeConverter();
|
||||||
|
$converters->add($dateTimeTypeConverter);
|
||||||
|
|
||||||
|
$this->assertSame(array($dateTimeTypeConverter), $converters->all());
|
||||||
|
|
||||||
|
$dateTypeConverter = new DateTypeConverter();
|
||||||
|
$converters->add($dateTypeConverter);
|
||||||
|
|
||||||
|
$this->assertSame(array($dateTimeTypeConverter, $dateTypeConverter), $converters->all());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue