sidfate / helpers
some common and useful helpers
1.0.0
2017-07-10 01:20 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2025-06-26 18:12:12 UTC
README
Some common and useful helpers in PHP
Install
composer require sidfate/helpers
composer require sidfate/helpers:dev-master
Usage
Arr
array functions.
use Helpers\Arr;
// Get the first value.
Arr::first(array $arr);
// Get the last value.
Arr::last(array $arr);
// Get the value if not exists return the default.
Arr::get(array $arr, $key, $default = null);
// Transform a array into object.
Arr::toObject(array $arr);
// Flatten a multi-dimensional array to a one-dimensional array.
Arr::flat(array $arr);
// Pluck the given key's value from a two-dimensional array.
Arr::pluck(array $arr, $key);
Str
string functions.
use Helpers\Str;
// Change the str to camel case.
Str::camel($str);
// * Get the limited str.
Str::limit($str, $length=50, $end="...");
Verify
verification functions.
use Helpers\Verify;
// Verify is a valid email address
Verify::isEmail($email)
// Verify is a valid ip address
Verify::isIp($ip)
// Verify is a valid url
Verify::isUrl($url)
Http
http functions.
use Helpers\Http;
// Get all HTTP headers
Http::getHeaders();
// Get the header value
Http::getHeader($key);
License
MIT