当前位置: 首页>>代码示例>>PHP>>正文


PHP Shape类代码示例

本文整理汇总了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());
 }
开发者ID:CodeLouisville,项目名称:php-exercise-oop,代码行数:8,代码来源:ShapeTest.php

示例2: __construct

 public function __construct($x, $y, $radius, $drawAPI)
 {
     Shape::__construct($drawAPI);
     $this->x = $x;
     $this->y = $y;
     $this->radius = $radius;
 }
开发者ID:possientis,项目名称:Prog,代码行数:7,代码来源:bridge.php

示例3: __construct

 public function __construct($id, $width, $height)
 {
     Shape::setID($id);
     $this->setHeight($height);
     $this->setWidth($width);
     $this->setArea();
 }
开发者ID:lctstitchlabstest,项目名称:FtL,代码行数:7,代码来源:Rectangle.php

示例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;
 }
开发者ID:abdala,项目名称:generic-api-client,代码行数:10,代码来源:MapShape.php

示例5: CircleShape

 public function CircleShape($x, $y, $radius, DrawingAPI $drawingAPI)
 {
     parent::Shape($drawingAPI);
     $this->x = $x;
     $this->y = $y;
     $this->radius = $radius;
 }
开发者ID:manachyn,项目名称:trainings,代码行数:7,代码来源:BridgeWiki_en.php

示例6: __construct

 public function __construct(array $definition, ShapeMap $shapeMap)
 {
     $definition['type'] = 'structure';
     if (!isset($definition['members'])) {
         $definition['members'] = [];
     }
     parent::__construct($definition, $shapeMap);
 }
开发者ID:ossistyle,项目名称:http-client-description,代码行数:8,代码来源:StructureShape.php

示例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;
 }
开发者ID:ossistyle,项目名称:http-client-description,代码行数:15,代码来源:ListShape.php

示例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;
 }
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:27,代码来源:ShapeMap.php

示例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));
 }
开发者ID:arogulin,项目名称:shapes,代码行数:11,代码来源:ShapesTest.php

示例10: __construct

 public function __construct(array $definition, ShapeMap $shapeMap)
 {
     $definition['type'] = 'timestamp';
     parent::__construct($definition, $shapeMap);
 }
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:5,代码来源:TimestampShape.php

示例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();
开发者ID:matteo-hertel,项目名称:archive,代码行数:16,代码来源:index.php

示例12: __construct

 public function __construct($x, $y, $radius, IDrawer $drawer)
 {
     parent::__construct($drawer);
     $this->x = $x;
     $this->y = $y;
     $this->radius = $radius;
 }
开发者ID:manachyn,项目名称:trainings,代码行数:7,代码来源:BridgeWiki.php

示例13: __construct

 public function __construct($dp, $x, $y, $r)
 {
     parent::__construct($dp);
     $this->_x = $x;
     $this->_y = $y;
     $this->_r = $r;
 }
开发者ID:nouka,项目名称:DesignPatternsExplained,代码行数:7,代码来源:10-3.php

示例14: __construct

 public function __construct($dX, $dY, $dRadius, DrawingAPI $oDrawingAPI)
 {
     parent::__construct($oDrawingAPI);
     $this->dX = $dX;
     $this->dY = $dY;
     $this->dRadius = $dRadius;
 }
开发者ID:ymnl007,项目名称:designpatterns,代码行数:7,代码来源:draw.php

示例15: __construct

 public function __construct($x, $y, $radius, DrawingAPI $api)
 {
     parent::__construct($api);
     $this->x = $x;
     $this->y = $y;
     $this->radius = $radius;
 }
开发者ID:boiler256,项目名称:PHP-design-patterns-1,代码行数:7,代码来源:Bridge.php


注:本文中的Shape类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。