misantron/php-utils

A collection of PHP utility classes.

2.0.0 2015-06-24 15:10 UTC

This package is auto-updated.

Last update: 2024-11-29 04:57:36 UTC


README

Build Status Code Coverage Code Climate Latest Release

Features

  • Contains Array, String and Time helper utilities.
  • Base encoding - UTF-8
  • PSR-4 auto loading standard compatible.

Server requirements

  • PHP version >= 5.4.
  • MBString PHP extension.
  • OpenSSL PHP extension.

External dependencies

Installing

The preferred way to install is through Composer. Run this command to install the latest stable version:

$ composer require misantron/php-utils

or add

"misantron/php-utils": "dev-master"

to the require section of your composer.json.

Basic usage examples

use Utility\UArray;  
use Utility\UString;  
use Utility\UTime;

$array = [  
    ['name' => 'Alex', 'age' => 25],  
    ['name' => 'Sara', 'age' => 21],  
    ['name' => 'John', 'age' => 28]  
];  
$string = '..C’est du français !';  
$date1 = new \DateTime('2015-02-26 13:05');  
$date2 = new \DateTime('2015-02-26 22:16');  

$result1 = UArray::extractColumn($array, 'age');  
$result2 = UString::slug($string);  
$result3 = UTime::secondsDiff($date1, $date2);

var_dump($result1, $result2, $result3);

[25, 21, 28];  
'c-est-du-francais';  
33060;