當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。