The bundle is back!
The definition of service has changed, read the README.
This commit is contained in:
@ -16,8 +16,8 @@ namespace Bundle\WebServiceBundle\Util;
|
||||
*/
|
||||
class Assert
|
||||
{
|
||||
const ARGUMENT_INVALID = "Argument '%s' is invalid!";
|
||||
const ARGUMENT_NULL = "Argument '%s' can't be null!";
|
||||
const ARGUMENT_INVALID = 'Argument "%s" is invalid.';
|
||||
const ARGUMENT_NULL = 'Argument "%s" can not be null.';
|
||||
|
||||
public static function thatArgument($name, $condition, $message = self::ARGUMENT_INVALID)
|
||||
{
|
||||
@ -28,6 +28,6 @@ class Assert
|
||||
|
||||
public static function thatArgumentNotNull($name, $value)
|
||||
{
|
||||
self::thatArgument($name, $value != null, self::ARGUMENT_NULL);
|
||||
self::thatArgument($name, null !== $value, self::ARGUMENT_NULL);
|
||||
}
|
||||
}
|
||||
|
@ -13,16 +13,23 @@ namespace Bundle\WebServiceBundle\Util;
|
||||
class Collection implements \IteratorAggregate, \Countable
|
||||
{
|
||||
private $elements = array();
|
||||
private $keyPropertyGetter;
|
||||
private $getter;
|
||||
private $class;
|
||||
|
||||
public function __construct($keyPropertyGetter)
|
||||
public function __construct($getter, $class = null)
|
||||
{
|
||||
$this->keyPropertyGetter = $keyPropertyGetter;
|
||||
$this->getter = $getter;
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function add($element)
|
||||
{
|
||||
$this->elements[call_user_func(array($element, $this->keyPropertyGetter))] = $element;
|
||||
if ($this->class && !$element instanceof $this->class) {
|
||||
throw new \InvalidArgument(sprintf('Cannot add class "%s" because it is not an instance of "%s"', get_class($element), $class));
|
||||
}
|
||||
|
||||
$getter = $this->getter;
|
||||
$this->elements[$element->$getter()] = $element;
|
||||
}
|
||||
|
||||
public function addAll($elements)
|
||||
@ -52,7 +59,7 @@ class Collection implements \IteratorAggregate, \Countable
|
||||
return count($this->elements);
|
||||
}
|
||||
|
||||
public function getIterator ()
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator($this->elements);
|
||||
}
|
||||
|
@ -11,11 +11,13 @@
|
||||
namespace Bundle\WebServiceBundle\Util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class QName
|
||||
{
|
||||
private $namespace;
|
||||
private $name;
|
||||
|
||||
public static function fromPackedQName($qname)
|
||||
{
|
||||
Assert::thatArgument('qname', preg_match('/^\{(.+)\}(.+)$/', $qname, $matches));
|
||||
@ -23,9 +25,6 @@ class QName
|
||||
return new self($matches[1], $matches[2]);
|
||||
}
|
||||
|
||||
private $namespace;
|
||||
private $name;
|
||||
|
||||
public function __construct($namespace, $name)
|
||||
{
|
||||
$this->namespace = $namespace;
|
||||
|
@ -17,14 +17,14 @@ namespace Bundle\WebServiceBundle\Util;
|
||||
*/
|
||||
class String
|
||||
{
|
||||
/**
|
||||
* Checks if a string starts with a given string.
|
||||
*
|
||||
* @param string $str A string
|
||||
* @param string $substr A string to check against
|
||||
*
|
||||
* @return bool True if str starts with substr
|
||||
*/
|
||||
/**
|
||||
* Checks if a string starts with a given string.
|
||||
*
|
||||
* @param string $str A string
|
||||
* @param string $substr A string to check against
|
||||
*
|
||||
* @return bool True if str starts with substr
|
||||
*/
|
||||
public static function startsWith($str, $substr)
|
||||
{
|
||||
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
|
||||
@ -33,17 +33,16 @@ class String
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string ends with a given string.
|
||||
*
|
||||
* @param string $str A string
|
||||
* @param string $substr A string to check against
|
||||
*
|
||||
* @return bool True if str ends with substr
|
||||
*/
|
||||
* Checks if a string ends with a given string.
|
||||
*
|
||||
* @param string $str A string
|
||||
* @param string $substr A string to check against
|
||||
*
|
||||
* @return bool True if str ends with substr
|
||||
*/
|
||||
public static function endsWith($str, $substr)
|
||||
{
|
||||
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr))
|
||||
{
|
||||
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
|
||||
return $substr == substr($str, strlen($str) - strlen($substr));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user