PHP code example of survos / shape-contracts

1. Go to this page and download the library: Download survos/shape-contracts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

survos / shape-contracts example snippets


use Survos\ShapeContracts\Length;
use Survos\ShapeContracts\Shape;
use Survos\ShapeContracts\Unit;

$shape = new Shape(
    width: Length::from(18, Unit::CM),
    height: Length::from(22, Unit::CM),
    source: '18 x 22 cm',
);

$shape->toNormalizedArray();
// [
//   'widthMm' => 180,
//   'heightMm' => 220,
//   'depthMm' => null,
//   'lengthMm' => null,
//   'thicknessMm' => null,
//   'diameterMm' => null,
//   'label' => null,
//   'source' => '18 x 22 cm',
// ]