PHP code example of namshi / utility-bundle

1. Go to this page and download the library: Download namshi/utility-bundle 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/ */

    

namshi / utility-bundle example snippets

 php
new Namshi\UtilityBundle\NamshiUtilityBundle(),
 php
/**
 * @var array
 *
 * @ORM\Column(name="tags", type="comma_separated_list", nullable=true)
 */
protected $tags = array();
 php


use Namshi\UtilityBundle\Currency\Converter;
use Namshi\UtilityBundle\Currency\Currency;
use Namshi\UtilityBundle\Exception\CurrencyNotFound;

$conversionRates = array(
  'EUR' => array(
    'USD' => 1.3,
  ),
  'USD' => array(
    'AED' => 4,
    'EUR' => 0.7,
  ),
);

$converter = new Converter($conversionRates);

try {
    echo $converter->convert(12, Currency::UNITED_STATES_DOLLAR, Currency::EURO)
} catch (CurrencyNotFound $e) {
    echo "Yo boss, can ya provide conversion rates here?";
}