PHP code example of skyzyx / utility-pack

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

    

skyzyx / utility-pack example snippets



use SimplePie\UtilityPack\Util\QueryString;

echo QueryString::build([
    'limit'  => 'a',
    'order'  => 'b',
    'offset' => 'c',
]);

#=> limit=a&order=b&offset=c


use SimplePie\UtilityPack\Util\Time;

echo sprintf('%s, %s, %s', 1 * Time::SECOND, 2 * Time::SECONDS, 10 * Time::SECONDS);
#=> 1, 2, 10

echo sprintf('%s, %s, %s', 1 * Time::MINUTE, 2 * Time::MINUTES, 10 * Time::MINUTES);
#=> 60, 120, 600

echo sprintf('%s, %s, %s', 1 * Time::HOUR, 2 * Time::HOURS, 10 * Time::HOURS);
#=> 3600, 7200, 36000

echo sprintf('%s, %s, %s', 1 * Time::DAY, 2 * Time::DAYS, 10 * Time::DAYS);
#=> 86400, 172800, 864000

echo sprintf('%s, %s, %s', 1 * Time::WEEK, 2 * Time::WEEKS, 10 * Time::WEEKS);
#=> 604800, 1209600, 6048000

echo 0.5 * Time::YEAR;
#=> 15778800


use SimplePie\UtilityPack\Util\Time;

echo gmdate(Time::FORMAT_ISO8601_ZULU);
#=> 2017-05-28T01:46:06Z


use SimplePie\UtilityPack\Util\Types;

echo Types::getClassOrType(
    new \SimpleXMLElement('<xml/>')
);
#=> SimpleXMLElement

echo Types::getClassOrType(
    new DateTime(
        'now',
        new DateTimeZone('UTC')
    )
);
#=> DateTime

echo Types::getClassOrType('string'));
#=> string

echo Types::getClassOrType(111));
#=> integer

echo Types::getClassOrType(111.0));
#=> double

echo Types::getClassOrType(true));
#=> boolean

echo Types::getClassOrType(false));
#=> boolean