arpadhegedus / utility
Utility classes for everyday php development
Requires (Dev)
- cvuorinen/phpdoc-markdown-public: 0.2.0
- phpdocumentor/phpdocumentor: 2.9
- phpunit/phpunit: ^8.3.3
README
Table of Contents
- Arr
- get
- group
- keys
- remove
- set
- sort
- sortKeys
- values
- abides
- abidesAny
- add
- dd
- dump
- merge
- getShallowType
- append
- average
- blueprint
- clean
- contains
- containsAll
- containsAny
- divide
- dot
- each
- filter
- find
- findAll
- first
- flatten
- has
- hasAll
- hasAny
- implode
- initial
- intersection
- intersects
- isAssoc
- isNumeric
- isSequential
- last
- map
- mapRecursive
- matches
- matchesAny
- max
- min
- normalize
- prepend
- pluck
- random
- range
- reject
- removeFirst
- removeLast
- removeValue
- repeat
- replace
- rest
- reverse
- search
- size
- undot
- unique
- without
- Chain
- Collection
- Func
- Geo
- Misc
- Num
- Obj
- Str
- abides
- abidesAny
- add
- dd
- dump
- merge
- getShallowType
- accord
- alpha
- alphaNumeric
- append
- ascii
- at
- base64
- between
- bool
- camel
- chars
- clean
- collapse
- common
- commonPrefix
- commonSuffix
- contains
- containsAll
- containsAny
- count
- dashed
- delimit
- endsWith
- endsWithAny
- ensureLeft
- ensureRight
- fileSize
- first
- htmlDecode
- htmlEncode
- index
- indexes
- insert
- isAlpha
- isAlphanumeric
- isBase64
- isBlank
- isEmail
- isHexadecimal
- isHTML
- isIP
- isJSON
- isLower
- isRegex
- isSerialized
- isUpper
- isURL
- last
- lastIndex
- length
- limit
- limitWords
- lines
- lower
- lowerFirst
- matches
- normalize
- ordinal
- pad
- padBoth
- padLeft
- padRight
- pascal
- prepend
- random
- regexReplace
- remove
- removeLeft
- removeRight
- repeat
- replace
- reverse
- shuffle
- slice
- slug
- slugify
- snake
- spacesToTabs
- split
- startsWith
- startsWithAny
- stringReplace
- stripWhitespace
- sub
- tabsToSpaces
- template
- timesContains
- title
- titlize
- trim
- trimLeft
- trimRight
- underscored
- upper
- upperFirst
- words
- URL
Arr
- Full name: \Utility\Arr
- Parent class: \Utility\Collection
get
Get a value of a $collection by a $key of $separator notation with $default fallback
Arr::get( array|object $collection, string $key = '', mixed $default = null, string $separator = '.' ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$default |
mixed | |
$separator |
string |
group
Group values from a $collection according to the results of a $callback
Arr::group( array|object $collection, callable $callback ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$callback |
callable |
keys
Get keys from a $collection
Arr::keys( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
remove
Remove a $key value in a $collection using $separator notation.
Arr::remove( array|object $collection, string|array $key, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string|array | |
$separator |
string |
set
Set a $value in a $collection using $separator notation.
Arr::set( array|object $collection, string $key, mixed $value, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$value |
mixed | |
$separator |
string |
sort
Sort a $collection by value, by a closure or by a property $sorter along a $direction
Arr::sort( array|object $collection, string $direction = 'ASC', null|callable|string $sorter = null ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string | |
$sorter |
null|callable|string |
sortKeys
Sort a $collection by keys or properties by $direction
Arr::sortKeys( array|object $collection, string $direction = 'ASC' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string |
values
Get values from a $collection
Arr::values( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
abides
Check if $data abides an array of $rules
Arr::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Arr::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Arr::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Arr::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Arr::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Arr::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Arr::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
append
Append a $value to an $array
Arr::append( array $array, mixed $value ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$value |
mixed |
average
Get average value of an $array
Arr::average( array $array, integer $decimals ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$decimals |
integer |
blueprint
Build an $array from a $ruleset blueprint and fallback $defaults
Arr::blueprint( array $array, array $ruleset, array $defaults = array() ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$ruleset |
array | |
$defaults |
array |
clean
Clean all falsy values from an array
Arr::clean( array $array, boolean $normalize = true ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$normalize |
boolean |
contains
Check if a $value is in an $array
Arr::contains( array $array, mixed $value ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$value |
mixed |
containsAll
Check if $array contains all $values
Arr::containsAll( array $array, array $values ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$values |
array |
containsAny
Check if $array contains any of the $values
Arr::containsAny( array $array, array $values ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$values |
array |
divide
Divide an $array into to arrays, the first containing the keys, the second the values
Arr::divide( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
dot
Flatten a multidimensional $array with $separator notation
Arr::dot( array $array, string $separator = '.', null|string $parent = null ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$separator |
string | |
$parent |
null|string |
each
Iterate over an $array and modify the array's values via $callback function
Arr::each( array $array, callable $callback, boolean $passKey = false ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$passKey |
boolean |
filter
Find all items in an $array that pass a $callback truth test
Arr::filter( array $array, callable $callback, string|integer $pass = 'value', boolean $normalize = false ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$pass |
string|integer | |
$normalize |
boolean |
find
Find the first item in an $array that passes $callback the truth test
Arr::find( array $array, callable $callback, boolean $passKey = false ): void|mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$passKey |
boolean |
findAll
Find all items in an $array that passes $callback truth test
Arr::findAll( array $array, callable $callback, boolean $passKey ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$passKey |
boolean |
first
Get the first $number of values from an $array
Arr::first( array $array, integer $number = 1 ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$number |
integer |
flatten
Flatten a multi-dimensional $array into a one-dimenisional array
Arr::flatten( array $array, boolean $preserveKeys = true ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$preserveKeys |
boolean |
has
Check if an $array has a $key
Arr::has( array $array, integer|string $key ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$key |
integer|string |
hasAll
Check if an $array has all $keys
Arr::hasAll( array $array, array $keys ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$keys |
array |
hasAny
Check if an $array has any of the $keys
Arr::hasAny( array $array, array $keys ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$keys |
array |
implode
Implode an $array
Arr::implode( array $array, string $glue = '' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$glue |
string |
initial
Get everything from $array but the last $number of items
Arr::initial( array $array, integer $number = 1 ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$number |
integer |
intersection
Return an array with all elements found in both $a and $b input arrays
Arr::intersection( array $a, array $b ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$a |
array | |
$b |
array |
intersects
Return if $a and $b input arrays intersect or not
Arr::intersects( array $a, array $b ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$a |
array | |
$b |
array |
isAssoc
Check if an $array is associative
Arr::isAssoc( array $array ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
isNumeric
Check if an $array only has numeric keys
Arr::isNumeric( array $array ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
isSequential
Check if $array is a numeric sequential array
Arr::isSequential( array $array ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
last
Get the last $number of values from an $array
Arr::last( array $array, integer $number = 1 ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$number |
integer |
map
Invoke a $callback function on all of the values in an $array
Arr::map( array $array, callable $callback, array $arguments = array() ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$arguments |
array |
mapRecursive
Invoke a $vallbackfunction on all of the values in an $array recursively
Arr::mapRecursive( array $array, callable $callback ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable |
matches
Check if all items in an $array match a $callback truth test
Arr::matches( array $array, callable $callback ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable |
matchesAny
Check if any item in an $array matches a $callback truth test
Arr::matchesAny( array $array, callable $callback ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable |
max
Get the max value of an $array
Arr::max( array $array, null|callable $callback = null ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
null|callable |
min
Get the min value of an $array
Arr::min( array $array, null|callable $callback = null ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
null|callable |
normalize
Normalize $array by sorting and filling missing keys
Arr::normalize( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
prepend
Prepend an $array with a $value
Arr::prepend( array $array, mixed $value ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$value |
mixed |
pluck
Get the value per $key from an $array of associative arrays
Arr::pluck( array $array, mixed $key, boolean $preserveKeys = true, boolean $keepEmpty = false ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$key |
mixed | |
$preserveKeys |
boolean | |
$keepEmpty |
boolean |
random
Get a $number of random values from an $array
Arr::random( array $array, integer $number = 1 ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$number |
integer |
range
Generate an array from a range starting from $base to $stop by $step
Arr::range( integer $base, integer $stop = null, integer $step = 1 ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$base |
integer | |
$stop |
integer | |
$step |
integer |
reject
Return all items from an $array that fail the $callback truth test
Arr::reject( array $array, callable $callback, boolean $passKey = false, boolean $normalize = false ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$callback |
callable | |
$passKey |
boolean | |
$normalize |
boolean |
removeFirst
Remove the first item from an $array
Arr::removeFirst( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
removeLast
Remove the last item from an array
Arr::removeLast( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
removeValue
Remove a $value from an $array
Arr::removeValue( array $array, mixed $value, boolean $normalize = true ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$value |
mixed | |
$normalize |
boolean |
repeat
Fill an array with some $data a number of $times
Arr::repeat( mixed $data, integer $times ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$times |
integer |
replace
Replace each $search word or pattern with $replacement inside $array
Arr::replace( array $array, string $search, string $replacement ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$search |
string | |
$replacement |
string |
rest
Get the last $number of items of an $array.
Arr::rest( array $array, integer $number = 1 ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$number |
integer |
reverse
Reverse an $array
Arr::reverse( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
search
Search for the index of a value in an array.
Arr::search( array $array, mixed $value ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$value |
mixed |
size
Get the size of an array.
Arr::size( array $array ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
undot
Unflatten a previously flattened $array using $separator notation
Arr::undot( array $array, string $separator = '.' ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$separator |
string |
unique
Remove duplicates from an array.
Arr::unique( array $array ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
without
Return an array without all instances of certain values.
Arr::without( array $array, mixed $values ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array | |
$values |
mixed |
Chain
- Full name: \Utility\Chain
__construct
Start a new chain
Chain::__construct( mixed $subject, string|object $class )
Parameters:
Parameter | Type | Description |
---|---|---|
$subject |
mixed | |
$class |
string|object |
break
Break the chain and return subject
Chain::break( ): mixed
swap
Swap Utility class along the chain
Chain::swap( string|object $class ): void
Parameters:
Parameter | Type | Description |
---|---|---|
$class |
string|object |
__call
Dispatch method calls to Utility class and pass in subject as the first argument
Chain::__call( string $method, array $arguments ): void
Parameters:
Parameter | Type | Description |
---|---|---|
$method |
string | |
$arguments |
array |
start
Start a new chain
Chain::start( mixed $subject, string|object $class ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$subject |
mixed | |
$class |
string|object |
Collection
- Full name: \Utility\Collection
- Parent class: \Utility\Misc
abides
Check if $data abides an array of $rules
Collection::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Collection::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Collection::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Collection::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Collection::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Collection::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Collection::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
get
Get a value of a $collection by a $key of $separator notation with $default fallback
Collection::get( array|object $collection, string $key = '', mixed $default = null, string $separator = '.' ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$default |
mixed | |
$separator |
string |
group
Group values from a $collection according to the results of a $callback
Collection::group( array|object $collection, callable $callback ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$callback |
callable |
keys
Get keys from a $collection
Collection::keys( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
remove
Remove a $key value in a $collection using $separator notation.
Collection::remove( array|object $collection, string|array $key, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string|array | |
$separator |
string |
set
Set a $value in a $collection using $separator notation.
Collection::set( array|object $collection, string $key, mixed $value, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$value |
mixed | |
$separator |
string |
sort
Sort a $collection by value, by a closure or by a property $sorter along a $direction
Collection::sort( array|object $collection, string $direction = 'ASC', null|callable|string $sorter = null ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string | |
$sorter |
null|callable|string |
sortKeys
Sort a $collection by keys or properties by $direction
Collection::sortKeys( array|object $collection, string $direction = 'ASC' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string |
values
Get values from a $collection
Collection::values( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
Func
- Full name: \Utility\Func
cache
Cache the return of a $function and return the value from cache in subsequent calls
Func::cache( callable $function ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$function |
callable |
call
Call a $function with $arguments whether it is a reference array string or an anonymus function
Func::call( null|callable $function, array $arguments = array() ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$function |
null|callable | |
$arguments |
array |
once
Limit a $function to be only called once
Func::once( callable $function, boolean $unique = false ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$function |
callable | |
$unique |
boolean |
only
Limit a $function to be only called a certain number of $times
Func::only( callable $function, integer $times = 1, boolean $unique = false ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$function |
callable | |
$times |
integer | |
$unique |
boolean |
throttle
Throttle a $function so that it can only be called once in every $miliseconds
Func::throttle( callable $function, integer $miliseconds = 300 ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$function |
callable | |
$miliseconds |
integer |
Geo
- Full name: \Utility\Geo
address
Get lat lng data from an address
Geo::address( string $address, array $apiParameters = array() ): null|string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$address |
string | |
$apiParameters |
array |
addressDistance
Calculate the distance between 2 pairs of lat and lng values
Geo::addressDistance( string $address1, string $address2, array $apiParameters = array(), string $unit = 'M' ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$address1 |
string | |
$address2 |
string | |
$apiParameters |
array | |
$unit |
string |
distance
Get the distance between 2 pairs of lat and lng values in various units
Geo::distance( float $lat1, float $lng1, float $lat2, float $lng2, string $unit = 'M' ): null|string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$lat1 |
float | |
$lng1 |
float | |
$lat2 |
float | |
$lng2 |
float | |
$unit |
string |
getAddress
Get geo data from an address
Geo::getAddress( string $address, array $apiParameters = array() )
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$address |
string | |
$apiParameters |
array |
getDistance
Calculate the distance between 2 pairs of lat and lng values
Geo::getDistance( float $lat1, float $lng1, float $lat2, float $lng2 ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$lat1 |
float | |
$lng1 |
float | |
$lat2 |
float | |
$lng2 |
float |
Misc
- Full name: \Utility\Misc
abides
Check if $data abides an array of $rules
Misc::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Misc::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Misc::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Misc::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Misc::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Misc::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Misc::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
Num
- Full name: \Utility\Num
- Parent class: \Utility\Misc
abides
Check if $data abides an array of $rules
Num::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Num::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Num::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Num::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Num::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Num::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Num::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
accord
Parse the $plural or $singular or $none template of a $number
Num::accord( float $number, string $plural, string $singular, string $none = '' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$plural |
string | |
$singular |
string | |
$none |
string |
fileSize
Get filesize from $bytes
Num::fileSize( float $bytes, integer $decimals ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$bytes |
float | |
$decimals |
integer |
format
Format $number
Num::format( float $number, integer $decimals, \Utility\string $decimalPoint = '.', \Utility\string $thousandSeparator = ',' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$decimals |
integer | |
$decimalPoint |
\Utility\string | |
$thousandSeparator |
\Utility\string |
isBetween
Check if $number is between $min and $max
Num::isBetween( float $number, float $min, float $max = 1 ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$min |
float | |
$max |
float |
isEven
Check if a $number is even
Num::isEven( float $number ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float |
isNegative
Check if a $number is negative
Num::isNegative( float $number ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float |
isOdd
Check if a $number is odd
Num::isOdd( float $number ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float |
isOutside
Check if a $number is outside of $min and $max
Num::isOutside( float $number, float $min, float $max = 1 ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$min |
float | |
$max |
float |
isPositive
Check if a $number is positive
Num::isPositive( float $number, boolean $zeroIncluded = false ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$zeroIncluded |
boolean |
limit
Limit $number to $min and $max values
Num::limit( float $number, float $min, float $max = 1 ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$min |
float | |
$max |
float |
max
Limit $number to a $max value
Num::max( float $number, float $max ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$max |
float |
min
Limit $number to a $min value
Num::min( float $number, float $min ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$min |
float |
ordinal
Get the ordinal form of a $number using a $template
Num::ordinal( float $number, string $template = '%number<sup>%ordinal</sup>' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$template |
string |
pad
Pad a $number to a $length with $pad from a $direction
Num::pad( float $number, integer $length, string $pad = '0', string $direction = 'left' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$length |
integer | |
$pad |
string | |
$direction |
string |
percentOf
Check the percentage of $number relative to $normal
Num::percentOf( float $number, float $normal = 100 ): float
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
float | |
$normal |
float |
Obj
- Full name: \Utility\Obj
- Parent class: \Utility\Collection
get
Get a value of a $collection by a $key of $separator notation with $default fallback
Obj::get( array|object $collection, string $key = '', mixed $default = null, string $separator = '.' ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$default |
mixed | |
$separator |
string |
group
Group values from a $collection according to the results of a $callback
Obj::group( array|object $collection, callable $callback ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$callback |
callable |
keys
Get keys from a $collection
Obj::keys( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
remove
Remove a $key value in a $collection using $separator notation.
Obj::remove( array|object $collection, string|array $key, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string|array | |
$separator |
string |
set
Set a $value in a $collection using $separator notation.
Obj::set( array|object $collection, string $key, mixed $value, string $separator = '.' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$key |
string | |
$value |
mixed | |
$separator |
string |
sort
Sort a $collection by value, by a closure or by a property $sorter along a $direction
Obj::sort( array|object $collection, string $direction = 'ASC', null|callable|string $sorter = null ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string | |
$sorter |
null|callable|string |
sortKeys
Sort a $collection by keys or properties by $direction
Obj::sortKeys( array|object $collection, string $direction = 'ASC' ): array|object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object | |
$direction |
string |
values
Get values from a $collection
Obj::values( array|object $collection ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$collection |
array|object |
abides
Check if $data abides an array of $rules
Obj::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Obj::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Obj::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Obj::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Obj::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Obj::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Obj::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
has
Check if an $object has a $key (property or method)
Obj::has( $object, string $key ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$object |
**** | |
$key |
string |
properties
Get all properties from an $object
Obj::properties( object $object ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$object |
object |
methods
Get all methods from an $object
Obj::methods( object $object ): null|array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$object |
object |
unpack
Unpack an $attribute from an $object
Obj::unpack( object $data, null|string $attribute = null ): object
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
object | |
$attribute |
null|string |
Str
- Full name: \Utility\Str
- Parent class: \Utility\Misc
abides
Check if $data abides an array of $rules
Str::abides( mixed $data, array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
array|callable |
abidesAny
Check if $data abides any of an array of $rules
Str::abidesAny( mixed $data, string|array|callable $rules = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed | |
$rules |
string|array|callable |
add
Add mixed $data to other mixed data cleverly
Str::add( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dd
Dump $data and die
Str::dd( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
dump
Dry dump $data for debug
Str::dump( mixed $data ): void
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
merge
Merge mixed $data to other mixed data cleverly
Str::merge( mixed $data ): mixed
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
getShallowType
Get a simplified type of a variable.
Str::getShallowType( mixed $data ): string
Return values: string|array|object|number|boolean|unknown
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$data |
mixed |
accord
Get $plural or $singular string depending on $number
Str::accord( string|float $number, string $plural, string $singular, string $none = '' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
string|float | |
$plural |
string | |
$singular |
string | |
$none |
string |
alpha
Convert a $string to alpha
Str::alpha( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
alphaNumeric
Convert a $string to alpha numeric
Str::alphaNumeric( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
append
Add $append to $string at the end
Str::append( string $string, string $append ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$append |
string |
ascii
Convert a $string to ASCII removing all accents
Str::ascii( string $string, string $language = 'en', boolean $removeUnsupported = true ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$language |
string | |
$removeUnsupported |
boolean |
at
Get character at a specific $index from a $string
Str::at( string $string, integer $index, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$index |
integer | |
$encoding |
null|string |
base64
Base 64 encode a $string
Str::base64( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
between
Get part of a $string between $start and $end substrings
Str::between( string $string, string $start, string $end, integer $offset, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$start |
string | |
$end |
string | |
$offset |
integer | |
$encoding |
null|string |
bool
Convert a $string to a bool
Str::bool( string $string, array $trueValues = array(), array $falseValues = array() ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$trueValues |
array | |
$falseValues |
array |
camel
Convert a $string to camelCase using a specific $language
Str::camel( string $string, string $language = '' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$language |
string |
chars
Get all distinct characters of a $string as an array
Str::chars( string $string, null|string $encoding = null ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
clean
Normalize and trim a $string
Str::clean( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
collapse
Ensure all white space characters only appear once in a $string
Str::collapse( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
common
Find a common sub string from $string and $otherString
Str::common( string $string, string $otherString, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$otherString |
string | |
$encoding |
null|string |
commonPrefix
Find a common prefix from $string and $otherString
Str::commonPrefix( string $string, string $otherString, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$otherString |
string | |
$encoding |
null|string |
commonSuffix
Find a common suffix from $string and $otherString
Str::commonSuffix( string $string, string $otherString, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$otherString |
string | |
$encoding |
null|string |
contains
Check if $string contains $needle
Str::contains( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
containsAll
Check if $string contains all substrings in a $needles array
Str::containsAll( string $string, array $needles, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needles |
array | |
$caseSensitive |
boolean | |
$encoding |
null|string |
containsAny
Check if $string contains any substrings in a $needles array
Str::containsAny( string $string, array $needles, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needles |
array | |
$caseSensitive |
boolean | |
$encoding |
null|string |
count
Count the characters in $string
Str::count( string $string, null|string $encoding = null ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
dashed
Delimit $string with dashes instead of spaces
Str::dashed( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
delimit
Connect words with $delimiter instead of spaces in $string
Str::delimit( string $string, string $delimiter, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$delimiter |
string | |
$encoding |
null|string |
endsWith
Check if $string ends with $needle
Str::endsWith( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
endsWithAny
Check if $string ends with any of the $needles
Str::endsWithAny( string $string, array $needles, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needles |
array | |
$caseSensitive |
boolean | |
$encoding |
null|string |
ensureLeft
Esnure $string starts with $ensure
Str::ensureLeft( string $string, string $ensure ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$ensure |
string |
ensureRight
Ensure $string ends with $ensure
Str::ensureRight( string $string, string $ensure ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$ensure |
string |
fileSize
Return a formatted filesize from $bytes
Str::fileSize( float|string $bytes, integer $decimals ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$bytes |
float|string | |
$decimals |
integer |
first
Get first $number characters from $string
Str::first( string $string, integer $number = 1, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$number |
integer | |
$encoding |
null|string |
htmlDecode
HTML decode $string
Str::htmlDecode( string $string, string $flags = ENT_COMPAT, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$flags |
string | |
$encoding |
null|string |
htmlEncode
HTML encode $string
Str::htmlEncode( string $string, string $flags = ENT_COMPAT, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$flags |
string | |
$encoding |
null|string |
index
Get position of $needle within $string
Str::index( string $string, string $needle, integer $offset, null|string $encoding = null ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$offset |
integer | |
$encoding |
null|string |
indexes
Get all positions of $needle within $string
Str::indexes( string $string, string $needle, null|string $encoding = null ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$encoding |
null|string |
insert
Push $insert into $string at the $index character
Str::insert( string $string, string $insert, integer $index, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$insert |
string | |
$index |
integer | |
$encoding |
null|string |
isAlpha
Check if $string is alfa
Str::isAlpha( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isAlphanumeric
Check if $string is alfa numeric
Str::isAlphanumeric( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isBase64
Check if $string is base 64 encoded
Str::isBase64( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isBlank
Check if $string is empty or has only white space
Str::isBlank( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isEmail
Check if $string is a valid email
Str::isEmail( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isHexadecimal
Check if $string is hexadecimal
Str::isHexadecimal( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isHTML
Check if $string contains HTML code
Str::isHTML( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isIP
Check if $string is a valid IP address
Str::isIP( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isJSON
Check if $string is valid JSON
Str::isJSON( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isLower
Check if $string is lower-case
Str::isLower( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isRegex
Check if $string is a valid regex
Str::isRegex( string $pattern ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$pattern |
string |
isSerialized
Check if $string is serialized
Str::isSerialized( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isUpper
Check if $string is upper case
Str::isUpper( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
isURL
Check if $string is a valid URL
Str::isURL( string $string ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
last
Get the last $number characters of a $string
Str::last( string $string, integer $number = 1, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$number |
integer | |
$encoding |
null|string |
lastIndex
Get last position of $needle in $string
Str::lastIndex( string $string, string $needle, integer $offset, null|string $encoding = null ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$offset |
integer | |
$encoding |
null|string |
length
Count length of $string
Str::length( string $string, null|string $encoding = null ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
limit
Safely truncate $string in $length
Str::limit( string $string, integer $length, string $append = '...', null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$append |
string | |
$encoding |
null|string |
limitWords
Limit $string to a $limit of words
Str::limitWords( string $string, integer $length, \Utility\string $append = '...' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$append |
\Utility\string |
lines
Get an array of lines in $string
Str::lines( string $string, boolean $trimEachLine = false ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$trimEachLine |
boolean |
lower
Convert $string to lower case
Str::lower( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
lowerFirst
Convert the first character of each word in $string to lower case
Str::lowerFirst( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
matches
Check if $string matches $pattern
Str::matches( string $string, string $pattern ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$pattern |
string |
normalize
Convert punctuation characters to a standardised, simpler version
Str::normalize( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
ordinal
Get ordinal version of $number according to $template
Str::ordinal( string|float $number, string $template = '%number<sup>%ordinal</sup>' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$number |
string|float | |
$template |
string |
pad
Add $pad to $string until it reaches $length
Str::pad( string $string, integer $length, string $pad = ' ', string $direction = 'right', null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$pad |
string | |
$direction |
string | |
$encoding |
null|string |
padBoth
Add $pad to both ends of a $string until it reaches $length
Str::padBoth( string $string, integer $length, string $pad = ' ', null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$pad |
string | |
$encoding |
null|string |
padLeft
Add $pad to the left side of a $string until it reaches $length
Str::padLeft( string $string, integer $length, string $pad = ' ', null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$pad |
string | |
$encoding |
null|string |
padRight
Add $pad to the right side of a $string until it reaches $length
Str::padRight( string $string, integer $length, string $pad = ' ', null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$length |
integer | |
$pad |
string | |
$encoding |
null|string |
pascal
Convert $string to PascalCase
Str::pascal( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
prepend
Add $prepend at the beginning of $string
Str::prepend( string $string, string $prepend ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$prepend |
string |
random
Generate random or $readable random string of $length
Str::random( integer $length = 10, boolean $readable = true ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$length |
integer | |
$readable |
boolean |
regexReplace
Replace $pattern with $replacement in $string
Str::regexReplace( string $string, string|array $pattern, string|array $replacement ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$pattern |
string|array | |
$replacement |
string|array |
remove
Remove $search pattern from $string
Str::remove( string $string, string $search ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$search |
string |
removeLeft
Remove $needle from the beginning of $string
Str::removeLeft( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
removeRight
Remove $needle from the end of $string
Str::removeRight( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
repeat
Repeat $string $times
Str::repeat( string $string, \Utility\int $times ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$times |
\Utility\int |
replace
Replace $search string with $replacement in $string
Str::replace( string $string, string $search, string $replacement ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$search |
string | |
$replacement |
string |
reverse
Reverse the characters of $string
Str::reverse( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
shuffle
Randomly shuffle the characters of $string
Str::shuffle( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
slice
Cut $string from $start to $end
Str::slice( string $string, integer $start, null|integer $end = null, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$start |
integer | |
$end |
null|integer | |
$encoding |
null|string |
slug
Convert $string to slug-case
Str::slug( string $string, string $language = 'en' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$language |
string |
slugify
Remove special characters and change whitespace characters with $delimiter in $string
Str::slugify( string $string, string $delimiter = '-', string $language = 'en' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$delimiter |
string | |
$language |
string |
snake
Convert $string to snake_case
Str::snake( string $string, string $language = 'en' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$language |
string |
spacesToTabs
Convert spaces to tabs in $string
Str::spacesToTabs( string $string, integer $tabLength = 4 ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$tabLength |
integer |
split
Split $string at $pattern
Str::split( string $string, string $pattern = '', null|integer $limit = null ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$pattern |
string | |
$limit |
null|integer |
startsWith
Check if $string starts with $needle
Str::startsWith( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
startsWithAny
Check if $string starts with any $needles
Str::startsWithAny( string $string, array $needles, boolean $caseSensitive = false, null|string $encoding = null ): boolean
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needles |
array | |
$caseSensitive |
boolean | |
$encoding |
null|string |
stringReplace
Swap $search with $replacement in $string
Str::stringReplace( string $string, string $search, string $replacement ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$search |
string | |
$replacement |
string |
stripWhitespace
Remove all white space characters from $string
Str::stripWhitespace( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
sub
Cut $string from $start to a certain $length
Str::sub( string $string, integer $start, null|integer $length = null, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$start |
integer | |
$length |
null|integer | |
$encoding |
null|string |
tabsToSpaces
Convert tabs to spaces in $string
Str::tabsToSpaces( string $string, $tabLength = 4 ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$tabLength |
**** |
template
Replace template variables in $string according to associate $data array
Str::template( string $string, array $data = array(), string $varSymbol = '%' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$data |
array | |
$varSymbol |
string |
timesContains
Count how many times $string contains $needle
Str::timesContains( string $string, string $needle, boolean $caseSensitive = false, null|string $encoding = null ): integer
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$needle |
string | |
$caseSensitive |
boolean | |
$encoding |
null|string |
title
Convert $string to Title Case
Str::title( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
titlize
Convert $string to Title Case with an $ignore list of words that would not be converted to uppercase
Str::titlize( string $string, array $ignore = array(), null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$ignore |
array | |
$encoding |
null|string |
trim
Trim $characters from each end of a $string
Str::trim( string $string, string $characters = ' ' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$characters |
string |
trimLeft
Trim $characters from the left side of $string
Str::trimLeft( string $string, string $characters = ' ' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$characters |
string |
trimRight
Trim $characters from the right side of $string
Str::trimRight( string $string, string $characters = ' ' ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$characters |
string |
underscored
Replace spaces with _ (underscores) in $string
Str::underscored( string $string ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string |
upper
Convert string to UPPER CASE
Str::upper( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
upperFirst
Upper Case first character of each word in $string
Str::upperFirst( string $string, null|string $encoding = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$encoding |
null|string |
words
Get an array of words from $string
Str::words( string $string, boolean $unique = true ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$string |
string | |
$unique |
boolean |
URL
- Full name: \Utility\URL
auth
Add $user and $pass to a $url
URL::auth( null|string|array $url, string $user, null|string $pass = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$user |
string | |
$pass |
null|string |
build
Build a URL from a parsed array
URL::build( array $url ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
array |
current
Get the current URL or its $parts
URL::current( array $parts = array() ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$parts |
array |
fragment
Get or $set the fragment of a $url
URL::fragment( null|string|array $url, null|string $set = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
null|string |
fragmentSet
Set $fragment part of a $url
URL::fragmentSet( null|string|array $url, string $fragment ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$fragment |
string |
host
Get or $set the host of a $url
URL::host( null|string|array $url, null|string $set = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
null|string |
hostSet
Set $host part of a $url
URL::hostSet( null|string|array $url, string $host ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$host |
string |
parse
Consistently parse $url
URL::parse( string $url ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
string |
parts
Get $parts of a $url
URL::parts( null|string|array $url, $parts = array('scheme', 'host', 'path') ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$parts |
**** |
pass
Get the pass part of a $url
URL::pass( null|string|array $url ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array |
path
Get or $set the path of a $url
URL::path( null|string|array $url, null|string $set = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
null|string |
pathRemove
Remove $search string or pattern from $url path
URL::pathRemove( null|string|array $url, \Utility\string $search ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$search |
\Utility\string |
pathSet
Set $path part of a $url
URL::pathSet( null|string|array $url, null|string $path ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$path |
null|string |
port
Get or $set the port of a $url
URL::port( null|string|array $url, boolean $set = false ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
boolean |
portSet
Set $port part of a $url
URL::portSet( null|string|array $url, string|integer $port ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$port |
string|integer |
query
Get or $set the query of a $url
URL::query( null|string|array $url, boolean $set = false ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
boolean |
queryAdd
Add a parameter $key and $value to the query of the $url
URL::queryAdd( null|string|array $url, string $key, mixed $value ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$key |
string | |
$value |
mixed |
queryArray
Get the array of query args from a $url
URL::queryArray( null|string|array $url ): array
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array |
queryGet
Get a query parameter from a URL
URL::queryGet( null|string|array $url, string $parameter ): string|null
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$parameter |
string |
queryRemove
Remove a parameter by $key from the query of the $url
URL::queryRemove( null|string|array $url, $keys ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$keys |
**** |
querySet
Set the $url path part to $data
URL::querySet( null|string|array $url, string|array $data ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$data |
string|array |
scheme
Get or $set the scheme of a $url
URL::scheme( null|string|array $url, null|string $set = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
null|string |
schemeSet
Set $scheme part of a $url
URL::schemeSet( null|string|array $url, null|string $scheme ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$scheme |
null|string |
user
Get the user part of a $url
URL::user( null|string|array $url, null|string $set = null ): string
- This method is static. Parameters:
Parameter | Type | Description |
---|---|---|
$url |
null|string|array | |
$set |
null|string |
This document was automatically generated from source code comments on 2019-08-07 using phpDocumentor and cvuorinen/phpdoc-markdown-public