本文整理汇总了PHP中Shape类的典型用法代码示例。如果您正苦于以下问题:PHP Shape类的具体用法?PHP Shape怎么用?PHP Shape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_getFullDescription
public function test_getFullDescription()
{
$shape = new Shape(4, 5);
$id = $shape->getId();
$name = str_shuffle(time());
$shape->name = $name;
$this->assertEquals('Shape<#' . $id . '>: ' . $name . ' - 4 x 5', $shape->getFullDescription());
}
示例2: __construct
public function __construct($x, $y, $radius, $drawAPI)
{
Shape::__construct($drawAPI);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
示例3: __construct
public function __construct($id, $width, $height)
{
Shape::setID($id);
$this->setHeight($height);
$this->setWidth($width);
$this->setArea();
}
示例4: 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;
}
示例5: CircleShape
public function CircleShape($x, $y, $radius, DrawingAPI $drawingAPI)
{
parent::Shape($drawingAPI);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
示例6: __construct
public function __construct(array $definition, ShapeMap $shapeMap)
{
$definition['type'] = 'structure';
if (!isset($definition['members'])) {
$definition['members'] = [];
}
parent::__construct($definition, $shapeMap);
}
示例7: 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;
}
示例8: 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;
}
示例9: testResize
/**
* @dataProvider providerResize
* @param Shape $shape
* @param float $factor
*/
public function testResize(Shape $shape, $factor)
{
$expectedPerimeter = round($shape->getPerimeter() * $factor, 2);
$shape->scale($factor);
$this->assertEquals($expectedPerimeter, round($shape->getPerimeter(), 2));
}
示例10: __construct
public function __construct(array $definition, ShapeMap $shapeMap)
{
$definition['type'] = 'timestamp';
parent::__construct($definition, $shapeMap);
}
示例11:
<?php
/**
* Copyright (c) 2014 Keith Casey.
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'shapes.php';
$shape = Shape::getShape('circle', 3);
// This should output 9*Pi
echo $shape->getArea();
$shape = Shape::getShape('square', 3);
// This should output 9
echo $shape->getArea();
示例12: __construct
public function __construct($x, $y, $radius, IDrawer $drawer)
{
parent::__construct($drawer);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}
示例13: __construct
public function __construct($dp, $x, $y, $r)
{
parent::__construct($dp);
$this->_x = $x;
$this->_y = $y;
$this->_r = $r;
}
示例14: __construct
public function __construct($dX, $dY, $dRadius, DrawingAPI $oDrawingAPI)
{
parent::__construct($oDrawingAPI);
$this->dX = $dX;
$this->dY = $dY;
$this->dRadius = $dRadius;
}
示例15: __construct
public function __construct($x, $y, $radius, DrawingAPI $api)
{
parent::__construct($api);
$this->x = $x;
$this->y = $y;
$this->radius = $radius;
}