2011-02-03 01:07:08 +01:00
|
|
|
<?php
|
|
|
|
/*
|
2011-07-18 22:43:12 +02:00
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
2011-02-03 01:07:08 +01:00
|
|
|
*
|
|
|
|
* (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.
|
|
|
|
*/
|
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
namespace BeSimple\SoapBundle\Util;
|
2011-02-03 01:07:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
|
|
|
*/
|
|
|
|
class QName
|
|
|
|
{
|
2011-07-17 10:46:54 +02:00
|
|
|
private $namespace;
|
|
|
|
private $name;
|
|
|
|
|
2011-07-17 15:08:46 +02:00
|
|
|
public static function isPrefixedQName($qname)
|
|
|
|
{
|
|
|
|
return false !== strpos($qname, ':') ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fromPrefixedQName($qname, $resolveNamespacePrefixCallable)
|
|
|
|
{
|
|
|
|
Assert::thatArgument('qname', self::isPrefixedQName($qname));
|
|
|
|
|
|
|
|
list($prefix, $name) = explode(':', $qname);
|
|
|
|
|
|
|
|
return new self(call_user_func($resolveNamespacePrefixCallable, $prefix), $name);
|
|
|
|
}
|
|
|
|
|
2011-02-03 01:07:08 +01:00
|
|
|
public static function fromPackedQName($qname)
|
|
|
|
{
|
|
|
|
Assert::thatArgument('qname', preg_match('/^\{(.+)\}(.+)$/', $qname, $matches));
|
|
|
|
|
|
|
|
return new self($matches[1], $matches[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __construct($namespace, $name)
|
|
|
|
{
|
|
|
|
$this->namespace = $namespace;
|
2011-07-17 15:08:46 +02:00
|
|
|
$this->name = $name;
|
2011-02-03 01:07:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getNamespace()
|
|
|
|
{
|
|
|
|
return $this->namespace;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return sprintf('{%s}%s', $this->getNamespace(), $this->getName());
|
|
|
|
}
|
|
|
|
}
|