dimitrievski/shapegen
Composer 安装命令:
composer require dimitrievski/shapegen
包简介
Generates 2D shapes in different sizes
README 文档
README
Generates 2D shapes (circles, ellipses, diamonds, squares, rectangles, triangles) in different sizes.
Requirements
PHP 7.0 and later.
Composer
You can install the bindings via Composer. Run the following command:
$ composer require dimitrievski/shapegen
To use the bindings, use Composer's autoload:
<?php require __DIR__ . '/vendor/autoload.php';
Getting Started
Simple usage looks like:
<?php $shapeGen = new \ShapeGen\ShapeGen(); echo $shapeGen->generate("diamond"); // X // XXXXX //XXXXXXXXX // XXXXX // X
To generate a shape with different size, pass an additional argument - number of lines. This argument must be an odd number between 5 and 49. The default is 5.
<?php $shapeGen = new \ShapeGen\ShapeGen(); echo $shapeGen->generate("diamond", 9); // X // XXXXX // XXXXXXXXX // XXXXXXXXXXXXX //XXXXXXXXXXXXXXXXX // XXXXXXXXXXXXX // XXXXXXXXX // XXXXX // X
To generate a shape with different filling, pass one more argument - filling character. This argument must be a string. The default is X.
<?php $shapeGen = new \ShapeGen\ShapeGen(); echo $shapeGen->generate("diamond", 9, "D"); // D // DDDDD // DDDDDDDDD // DDDDDDDDDDDDD //DDDDDDDDDDDDDDDDD // DDDDDDDDDDDDD // DDDDDDDDD // DDDDD // D
To create new shapes, use the shape factory like:
<?php $shapeFactory = new \ShapeGen\ShapeFactory(); $diamond = $shapeFactory->create("diamond"); //set different size and filling $diamond->setLines(15); $diamond->setFilling("-"); echo $diamond->generate(); // - // ----- // --------- // ------------- // ----------------- // --------------------- // ------------------------- //----------------------------- // ------------------------- // --------------------- // ----------------- // ------------- // --------- // ----- // -
Development
Install dependencies:
$ composer install
Tests
Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:
$ ./vendor/bin/phpunit tests/
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-24