PHP code example of bakame / shoe-size-converter

1. Go to this page and download the library: Download bakame/shoe-size-converter 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/ */

    

bakame / shoe-size-converter example snippets


use Bakame\Shoes\AdultUnit;
use Bakame\Shoes\ChildUnit;

$euShoeSize = AdultUnit::Eu->of(43);
// $euShoeSize is an instance of Bakame\Shoes\AdultSize
$ukChildSize = ChildUnit::Uk->of(7.5);
// $ukChildSize is an instance of Bakame\Shoes\ChildSize

$euShoeSize->size;
// 43

$euShoeSize->unit;
// AdultUnit::Eu

$euShoeSize->label();
// EU 43

$ukShoeSize = $euShoeSize->in(AdultUnit::Uk);
// returns an AdultSize containing the calculated UK size

$ukShoeSize->size;
// 9.5

$ukShoeSize->unit;
// AdultUnit::Uk

$result = $euShoeSize->equivalents();
// returns an array containing the calculated equivalent shoe sizes
// for all supported adult units

use Bakame\Shoes\Length;
use Bakame\Shoes\LengthUnit;

$footLength = $ukShoeSize->footLength;
// returns a Bakame\Shoes\Length instance

$footLength->in(LengthUnit::Millimeter);
// returns the length in millimeters 275

$footLength->in(LengthUnit::Centimeter);
// returns the length in centimeters 27.5

$footLength->in(LengthUnit::Inch);
// returns the length in inches 10.826771653543

use Bakame\Shoes\Length;

Length::compare($ukShoeSize, $euShoeSize);
// returns -1, 0, or 1

$footLength = $converter->footLength($ukChildSize);

$footLength->in(LengthUnit::Centimeter);
// returns the length found in the conversion table
// converted to centimeters

$ukShoeSize = $converter->size($euShoeSize, AdultUnit::Uk);
// returns the UK equivalent found in the conversion table

$result = $converter->equivalents($euShoeSize);
// returns the equivalent shoe sizes found in the conversion table
bash
php -S localhost:4000