本文整理汇总了PHP中Shape::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Shape::create方法的具体用法?PHP Shape::create怎么用?PHP Shape::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKey
/**
* @return Shape
*/
public function getKey()
{
if (!$this->key) {
$this->key = isset($this->definition['key']) ? Shape::create($this->definition['key'], $this->shapeMap) : new Shape(['type' => 'string'], $this->shapeMap);
}
return $this->key;
}
示例2: getMember
/**
* @return Shape
*
* @throws \RuntimeException if no member is specified
*/
public function getMember()
{
if (!$this->member) {
if (!isset($this->definition['member'])) {
throw new \RuntimeException('No member attribute specified');
}
$this->member = Shape::create($this->definition['member'], $this->shapeMap);
}
return $this->member;
}
示例3: resolve
/**
* Resolve a shape reference
*
* @param array $shapeRef Shape reference shape
*
* @return Shape
* @throws \InvalidArgumentException
*/
public function resolve(array $shapeRef)
{
$shape = $shapeRef['shape'];
if (!isset($this->definitions[$shape])) {
throw new \InvalidArgumentException('Shape not found: ' . $shape);
}
$isSimple = count($shapeRef) == 1;
if ($isSimple && isset($this->simple[$shape])) {
return $this->simple[$shape];
}
$definition = $shapeRef + $this->definitions[$shape];
$definition['name'] = $definition['shape'];
unset($definition['shape']);
$result = Shape::create($definition, $this);
if ($isSimple) {
$this->simple[$shape] = $result;
}
return $result;
}
示例4: shapeFor
protected function shapeFor(array $definition)
{
return isset($definition['shape']) ? $this->shapeMap->resolve($definition) : Shape::create($definition, $this->shapeMap);
}