Download the PHP package arpadhegedus/utility without Composer

On this page you can find all versions of the php package arpadhegedus/utility. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package utility

Utility

Table of Contents

Arr

get

Get a value of a $collection by a $key of $separator notation with $default fallback

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

Parameter Type Description
$collection array|object
$callback callable

keys

Get keys from a $collection

Parameter Type Description
$collection array|object

remove

Remove a $key value in a $collection using $separator notation.

Parameter Type Description
$collection array|object
$key string|array
$separator string

set

Set a $value in a $collection using $separator notation.

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

Parameter Type Description
$collection array|object
$direction string
$sorter null|callable|string

sortKeys

Sort a $collection by keys or properties by $direction

Parameter Type Description
$collection array|object
$direction string

values

Get values from a $collection

Parameter Type Description
$collection array|object

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

append

Append a $value to an $array

Parameter Type Description
$array array
$value mixed

average

Get average value of an $array

Parameter Type Description
$array array
$decimals integer

blueprint

Build an $array from a $ruleset blueprint and fallback $defaults

Parameter Type Description
$array array
$ruleset array
$defaults array

clean

Clean all falsy values from an array

Parameter Type Description
$array array
$normalize boolean

contains

Check if a $value is in an $array

Parameter Type Description
$array array
$value mixed

containsAll

Check if $array contains all $values

Parameter Type Description
$array array
$values array

containsAny

Check if $array contains any of the $values

Parameter Type Description
$array array
$values array

divide

Divide an $array into to arrays, the first containing the keys, the second the values

Parameter Type Description
$array array

dot

Flatten a multidimensional $array with $separator notation

Parameter Type Description
$array array
$separator string
$parent null|string

each

Iterate over an $array and modify the array's values via $callback function

Parameter Type Description
$array array
$callback callable
$passKey boolean

filter

Find all items in an $array that pass a $callback truth test

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

Parameter Type Description
$array array
$callback callable
$passKey boolean

findAll

Find all items in an $array that passes $callback truth test

Parameter Type Description
$array array
$callback callable
$passKey boolean

first

Get the first $number of values from an $array

Parameter Type Description
$array array
$number integer

flatten

Flatten a multi-dimensional $array into a one-dimenisional array

Parameter Type Description
$array array
$preserveKeys boolean

has

Check if an $array has a $key

Parameter Type Description
$array array
$key integer|string

hasAll

Check if an $array has all $keys

Parameter Type Description
$array array
$keys array

hasAny

Check if an $array has any of the $keys

Parameter Type Description
$array array
$keys array

implode

Implode an $array

Parameter Type Description
$array array
$glue string

initial

Get everything from $array but the last $number of items

Parameter Type Description
$array array
$number integer

intersection

Return an array with all elements found in both $a and $b input arrays

Parameter Type Description
$a array
$b array

intersects

Return if $a and $b input arrays intersect or not

Parameter Type Description
$a array
$b array

isAssoc

Check if an $array is associative

Parameter Type Description
$array array

isNumeric

Check if an $array only has numeric keys

Parameter Type Description
$array array

isSequential

Check if $array is a numeric sequential array

Parameter Type Description
$array array

last

Get the last $number of values from an $array

Parameter Type Description
$array array
$number integer

map

Invoke a $callback function on all of the values in an $array

Parameter Type Description
$array array
$callback callable
$arguments array

mapRecursive

Invoke a $vallbackfunction on all of the values in an $array recursively

Parameter Type Description
$array array
$callback callable

matches

Check if all items in an $array match a $callback truth test

Parameter Type Description
$array array
$callback callable

matchesAny

Check if any item in an $array matches a $callback truth test

Parameter Type Description
$array array
$callback callable

max

Get the max value of an $array

Parameter Type Description
$array array
$callback null|callable

min

Get the min value of an $array

Parameter Type Description
$array array
$callback null|callable

normalize

Normalize $array by sorting and filling missing keys

Parameter Type Description
$array array

prepend

Prepend an $array with a $value

Parameter Type Description
$array array
$value mixed

pluck

Get the value per $key from an $array of associative arrays

Parameter Type Description
$array array
$key mixed
$preserveKeys boolean
$keepEmpty boolean

random

Get a $number of random values from an $array

Parameter Type Description
$array array
$number integer

range

Generate an array from a range starting from $base to $stop by $step

Parameter Type Description
$base integer
$stop integer
$step integer

reject

Return all items from an $array that fail the $callback truth test

Parameter Type Description
$array array
$callback callable
$passKey boolean
$normalize boolean

removeFirst

Remove the first item from an $array

Parameter Type Description
$array array

removeLast

Remove the last item from an array

Parameter Type Description
$array array

removeValue

Remove a $value from an $array

Parameter Type Description
$array array
$value mixed
$normalize boolean

repeat

Fill an array with some $data a number of $times

Parameter Type Description
$data mixed
$times integer

replace

Replace each $search word or pattern with $replacement inside $array

Parameter Type Description
$array array
$search string
$replacement string

rest

Get the last $number of items of an $array.

Parameter Type Description
$array array
$number integer

reverse

Reverse an $array

Parameter Type Description
$array array

search

Search for the index of a value in an array.

Parameter Type Description
$array array
$value mixed

size

Get the size of an array.

Parameter Type Description
$array array

undot

Unflatten a previously flattened $array using $separator notation

Parameter Type Description
$array array
$separator string

unique

Remove duplicates from an array.

Parameter Type Description
$array array

without

Return an array without all instances of certain values.

Parameter Type Description
$array array
$values mixed

Chain

__construct

Start a new chain

Parameters:

Parameter Type Description
$subject mixed
$class string|object

break

Break the chain and return subject


swap

Swap Utility class along the chain

Parameters:

Parameter Type Description
$class string|object

__call

Dispatch method calls to Utility class and pass in subject as the first argument

Parameters:

Parameter Type Description
$method string
$arguments array

start

Start a new chain

Parameter Type Description
$subject mixed
$class string|object

Collection

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

get

Get a value of a $collection by a $key of $separator notation with $default fallback

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

Parameter Type Description
$collection array|object
$callback callable

keys

Get keys from a $collection

Parameter Type Description
$collection array|object

remove

Remove a $key value in a $collection using $separator notation.

Parameter Type Description
$collection array|object
$key string|array
$separator string

set

Set a $value in a $collection using $separator notation.

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

Parameter Type Description
$collection array|object
$direction string
$sorter null|callable|string

sortKeys

Sort a $collection by keys or properties by $direction

Parameter Type Description
$collection array|object
$direction string

values

Get values from a $collection

Parameter Type Description
$collection array|object

Func

cache

Cache the return of a $function and return the value from cache in subsequent calls

Parameter Type Description
$function callable

call

Call a $function with $arguments whether it is a reference array string or an anonymus function

Parameter Type Description
$function null|callable
$arguments array

once

Limit a $function to be only called once

Parameter Type Description
$function callable
$unique boolean

only

Limit a $function to be only called a certain number of $times

Parameter Type Description
$function callable
$times integer
$unique boolean

throttle

Throttle a $function so that it can only be called once in every $miliseconds

Parameter Type Description
$function callable
$miliseconds integer

Geo

address

Get lat lng data from an address

Parameter Type Description
$address string
$apiParameters array

addressDistance

Calculate the distance between 2 pairs of lat and lng values

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

Parameter Type Description
$lat1 float
$lng1 float
$lat2 float
$lng2 float
$unit string

getAddress

Get geo data from an address

Parameter Type Description
$address string
$apiParameters array

getDistance

Calculate the distance between 2 pairs of lat and lng values

Parameter Type Description
$lat1 float
$lng1 float
$lat2 float
$lng2 float

Misc

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

Num

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

accord

Parse the $plural or $singular or $none template of a $number

Parameter Type Description
$number float
$plural string
$singular string
$none string

fileSize

Get filesize from $bytes

Parameter Type Description
$bytes float
$decimals integer

format

Format $number

Parameter Type Description
$number float
$decimals integer
$decimalPoint \Utility\string
$thousandSeparator \Utility\string

isBetween

Check if $number is between $min and $max

Parameter Type Description
$number float
$min float
$max float

isEven

Check if a $number is even

Parameter Type Description
$number float

isNegative

Check if a $number is negative

Parameter Type Description
$number float

isOdd

Check if a $number is odd

Parameter Type Description
$number float

isOutside

Check if a $number is outside of $min and $max

Parameter Type Description
$number float
$min float
$max float

isPositive

Check if a $number is positive

Parameter Type Description
$number float
$zeroIncluded boolean

limit

Limit $number to $min and $max values

Parameter Type Description
$number float
$min float
$max float

max

Limit $number to a $max value

Parameter Type Description
$number float
$max float

min

Limit $number to a $min value

Parameter Type Description
$number float
$min float

ordinal

Get the ordinal form of a $number using a $template

Parameter Type Description
$number float
$template string

pad

Pad a $number to a $length with $pad from a $direction

Parameter Type Description
$number float
$length integer
$pad string
$direction string

percentOf

Check the percentage of $number relative to $normal

Parameter Type Description
$number float
$normal float

Obj

get

Get a value of a $collection by a $key of $separator notation with $default fallback

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

Parameter Type Description
$collection array|object
$callback callable

keys

Get keys from a $collection

Parameter Type Description
$collection array|object

remove

Remove a $key value in a $collection using $separator notation.

Parameter Type Description
$collection array|object
$key string|array
$separator string

set

Set a $value in a $collection using $separator notation.

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

Parameter Type Description
$collection array|object
$direction string
$sorter null|callable|string

sortKeys

Sort a $collection by keys or properties by $direction

Parameter Type Description
$collection array|object
$direction string

values

Get values from a $collection

Parameter Type Description
$collection array|object

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

has

Check if an $object has a $key (property or method)

Parameter Type Description
$object ****
$key string

properties

Get all properties from an $object

Parameter Type Description
$object object

methods

Get all methods from an $object

Parameter Type Description
$object object

unpack

Unpack an $attribute from an $object

Parameter Type Description
$data object
$attribute null|string

Str

abides

Check if $data abides an array of $rules

Parameter Type Description
$data mixed
$rules array|callable

abidesAny

Check if $data abides any of an array of $rules

Parameter Type Description
$data mixed
$rules string|array|callable

add

Add mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

dd

Dump $data and die

Parameter Type Description
$data mixed

dump

Dry dump $data for debug

Parameter Type Description
$data mixed

merge

Merge mixed $data to other mixed data cleverly

Parameter Type Description
$data mixed

getShallowType

Get a simplified type of a variable.

Return values: string|array|object|number|boolean|unknown

Parameter Type Description
$data mixed

accord

Get $plural or $singular string depending on $number

Parameter Type Description
$number string|float
$plural string
$singular string
$none string

alpha

Convert a $string to alpha

Parameter Type Description
$string string

alphaNumeric

Convert a $string to alpha numeric

Parameter Type Description
$string string

append

Add $append to $string at the end

Parameter Type Description
$string string
$append string

ascii

Convert a $string to ASCII removing all accents

Parameter Type Description
$string string
$language string
$removeUnsupported boolean

at

Get character at a specific $index from a $string

Parameter Type Description
$string string
$index integer
$encoding null|string

base64

Base 64 encode a $string

Parameter Type Description
$string string

between

Get part of a $string between $start and $end substrings

Parameter Type Description
$string string
$start string
$end string
$offset integer
$encoding null|string

bool

Convert a $string to a bool

Parameter Type Description
$string string
$trueValues array
$falseValues array

camel

Convert a $string to camelCase using a specific $language

Parameter Type Description
$string string
$language string

chars

Get all distinct characters of a $string as an array

Parameter Type Description
$string string
$encoding null|string

clean

Normalize and trim a $string

Parameter Type Description
$string string

collapse

Ensure all white space characters only appear once in a $string

Parameter Type Description
$string string

common

Find a common sub string from $string and $otherString

Parameter Type Description
$string string
$otherString string
$encoding null|string

commonPrefix

Find a common prefix from $string and $otherString

Parameter Type Description
$string string
$otherString string
$encoding null|string

commonSuffix

Find a common suffix from $string and $otherString

Parameter Type Description
$string string
$otherString string
$encoding null|string

contains

Check if $string contains $needle

Parameter Type Description
$string string
$needle string
$caseSensitive boolean
$encoding null|string

containsAll

Check if $string contains all substrings in a $needles array

Parameter Type Description
$string string
$needles array
$caseSensitive boolean
$encoding null|string

containsAny

Check if $string contains any substrings in a $needles array

Parameter Type Description
$string string
$needles array
$caseSensitive boolean
$encoding null|string

count

Count the characters in $string

Parameter Type Description
$string string
$encoding null|string

dashed

Delimit $string with dashes instead of spaces

Parameter Type Description
$string string

delimit

Connect words with $delimiter instead of spaces in $string

Parameter Type Description
$string string
$delimiter string
$encoding null|string

endsWith

Check if $string ends with $needle

Parameter Type Description
$string string
$needle string
$caseSensitive boolean
$encoding null|string

endsWithAny

Check if $string ends with any of the $needles

Parameter Type Description
$string string
$needles array
$caseSensitive boolean
$encoding null|string

ensureLeft

Esnure $string starts with $ensure

Parameter Type Description
$string string
$ensure string

ensureRight

Ensure $string ends with $ensure

Parameter Type Description
$string string
$ensure string

fileSize

Return a formatted filesize from $bytes

Parameter Type Description
$bytes float|string
$decimals integer

first

Get first $number characters from $string

Parameter Type Description
$string string
$number integer
$encoding null|string

htmlDecode

HTML decode $string

Parameter Type Description
$string string
$flags string
$encoding null|string

htmlEncode

HTML encode $string

Parameter Type Description
$string string
$flags string
$encoding null|string

index

Get position of $needle within $string

Parameter Type Description
$string string
$needle string
$offset integer
$encoding null|string

indexes

Get all positions of $needle within $string

Parameter Type Description
$string string
$needle string
$encoding null|string

insert

Push $insert into $string at the $index character

Parameter Type Description
$string string
$insert string
$index integer
$encoding null|string

isAlpha

Check if $string is alfa

Parameter Type Description
$string string

isAlphanumeric

Check if $string is alfa numeric

Parameter Type Description
$string string

isBase64

Check if $string is base 64 encoded

Parameter Type Description
$string string

isBlank

Check if $string is empty or has only white space

Parameter Type Description
$string string

isEmail

Check if $string is a valid email

Parameter Type Description
$string string

isHexadecimal

Check if $string is hexadecimal

Parameter Type Description
$string string

isHTML

Check if $string contains HTML code

Parameter Type Description
$string string

isIP

Check if $string is a valid IP address

Parameter Type Description
$string string

isJSON

Check if $string is valid JSON

Parameter Type Description
$string string

isLower

Check if $string is lower-case

Parameter Type Description
$string string

isRegex

Check if $string is a valid regex

Parameter Type Description
$pattern string

isSerialized

Check if $string is serialized

Parameter Type Description
$string string

isUpper

Check if $string is upper case

Parameter Type Description
$string string

isURL

Check if $string is a valid URL

Parameter Type Description
$string string

last

Get the last $number characters of a $string

Parameter Type Description
$string string
$number integer
$encoding null|string

lastIndex

Get last position of $needle in $string

Parameter Type Description
$string string
$needle string
$offset integer
$encoding null|string

length

Count length of $string

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
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
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
Parameter Type Description
$string string
$trimEachLine boolean

lower

Convert $string to lower case

Str::lower( string $string, null|string $encoding = null ): string
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
Parameter Type Description
$string string
$encoding null|string

matches

Check if $string matches $pattern

Str::matches( string $string, string $pattern ): boolean
Parameter Type Description
$string string
$pattern string

normalize

Convert punctuation characters to a standardised, simpler version

Str::normalize( string $string ): string
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
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
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
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
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
Parameter Type Description
$string string
$length integer
$pad string
$encoding null|string

pascal

Convert $string to PascalCase

Str::pascal( string $string ): string
Parameter Type Description
$string string

prepend

Add $prepend at the beginning of $string

Str::prepend( string $string, string $prepend ): string
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
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
Parameter Type Description
$string string
$pattern string|array
$replacement string|array

remove

Remove $search pattern from $string

Str::remove( string $string, string $search ): string
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
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
Parameter Type Description
$string string
$needle string
$caseSensitive boolean
$encoding null|string

repeat

Repeat $string $times

Str::repeat( string $string, \Utility\int $times ): string
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
Parameter Type Description
$string string
$search string
$replacement string

reverse

Reverse the characters of $string

Str::reverse( string $string, null|string $encoding = null ): string
Parameter Type Description
$string string
$encoding null|string

shuffle

Randomly shuffle the characters of $string

Str::shuffle( string $string, null|string $encoding = null ): string
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
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
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
Parameter Type Description
$string string
$delimiter string
$language string

snake

Convert $string to snake_case

Str::snake( string $string, string $language = 'en' ): string
Parameter Type Description
$string string
$language string

spacesToTabs

Convert spaces to tabs in $string

Str::spacesToTabs( string $string, integer $tabLength = 4 ): string
Parameter Type Description
$string string
$tabLength integer

split

Split $string at $pattern

Str::split( string $string, string $pattern = '', null|integer $limit = null ): array
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
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
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
Parameter Type Description
$string string
$search string
$replacement string

stripWhitespace

Remove all white space characters from $string

Str::stripWhitespace( string $string ): string
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
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
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
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
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
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
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
Parameter Type Description
$string string
$characters string

trimLeft

Trim $characters from the left side of $string

Str::trimLeft( string $string, string $characters = ' ' ): string
Parameter Type Description
$string string
$characters string

trimRight

Trim $characters from the right side of $string

Str::trimRight( string $string, string $characters = ' ' ): string
Parameter Type Description
$string string
$characters string

underscored

Replace spaces with _ (underscores) in $string

Str::underscored( string $string ): string
Parameter Type Description
$string string

upper

Convert string to UPPER CASE

Str::upper( string $string, null|string $encoding = null ): string
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
Parameter Type Description
$string string
$encoding null|string

words

Get an array of words from $string

Str::words( string $string, boolean $unique = true ): array
Parameter Type Description
$string string
$unique boolean

URL

auth

Add $user and $pass to a $url

URL::auth( null|string|array $url, string $user, null|string $pass = null ): string
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
Parameter Type Description
$url array

current

Get the current URL or its $parts

URL::current( array $parts = array() ): string
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
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
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
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
Parameter Type Description
$url null|string|array
$host string

parse

Consistently parse $url

URL::parse( string $url ): array
Parameter Type Description
$url string

parts

Get $parts of a $url

URL::parts( null|string|array $url,  $parts = array('scheme', 'host', 'path') ): string
Parameter Type Description
$url null|string|array
$parts ****

pass

Get the pass part of a $url

URL::pass( null|string|array $url ): string
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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


All versions of utility with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package arpadhegedus/utility contains the following files

Loading the files please wait ....