PHP code example of phrity / o

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

    

phrity / o example snippets


$factory = new Factory();
$instance = $factory->convert([1, 2, 3]); // -> Arr instance

$str = new Str('hello world');
$str(); // Getter
$str('world'); // Setter

$int = new Integer(1234);
$int(); // Getter
$int(5678); // Setter

$num = new Number(12.34);
$num(); // Getter
$num(56.78); // Setter

$bool = new Boolean(true);
$bool(); // Getter
$bool(false); // Setter

$array = new Arr([1, 2, 3]);
$array[] = 7; // ArrayAccess support
count($array); // Countable support
foreach ($array as $key => $value) {} // Iterator support
$array->equals(new Arr([2, 3, 4])); // Comparison support

$object = new Obj(['a' => 1, 'b' => 2, 'c' => 3]);
$object->b = 5; // Property access
$object->equals(new Obj(['c' => 1, 'd' => 2])); // Comparison support

$queue = new Queue([1, 2, 3]);
$queue->enqueue(4);
$queue->dequeue();
count($queue); // Countable support
foreach ($queue as $key => $item) {} // Consuming iterator support
$queue->equals(new Queue([2, 3, 4])); // Comparison support

$stack = new Stack([1, 2, 3]);
$stack->push(4);
$stack->pop();
count($stack); // Countable support
foreach ($stack as $key => $item) {} // Consuming iterator support
$stack->equals(new Stack([2, 3, 4])); // Comparison support