PHP 클래스 Voodoo\Core\Helpers

파일 보기 프로젝트 열기: voodoophp/voodoo 1 사용 예제들

공개 메소드들

메소드 설명
CompressOutput ( $content, $print = true ) : To compress data in GZIP and print it.
TimeZoneList ( ) : Array All the timezone list by region
arrayExtend ( Array $a, Array $b ) : Array To extend an array with another array by merging the data and update them with new a
arrayFlatten ( array $ar, Array $f = [] ) : mixed To flatten multi dimensional array into a flat one. Also preserve the key
arrayToDotNotation ( type $Arr ) : type Convert an array to dot notation
array_merge_recursive_distinct ( ) Merges any number of arrays / parameters recursively, replacing entries with string keys with values from latter arrays.
array_msort ( $array, $cols ) : Array Array Multi sort wi $arr2 = array_msort($arr1, array('name'=>array(SORT_DESC,SORT_REGULAR), 'cat'=>SORT_ASC));
calculateDistance ( $lat1, $lon1, $lat2, $lon2, $unit = "M" ) : To calculate distance between to coordinaces
camelize ( type $string, type $pascalCase = false ) : type Camelize
convertCm2In ( $val ) : Cm to inches
convertCm2M ( $val ) : Cm to meters
convertIn2Cm ( $val ) : inches to cm
convertIn2Ft_human ( $val, $dumb = false ) : Human inches value and convert it to a human readable
convertM2Cm ( $val ) : Meters to cm
countWords ( $str ) To count total words in a string
createTagCloud ( array $Tags, string $Link = "", INT $cloud_spread, $sort = "count", string $title = "%tag%", boolean $sizeTags = false ) : String To create a tag cloud based on the tags provided
curlRequest ( string $url, mixed $params = [], string $method = "GET", array $curlOptions = [] ) : Array To make a simple curl request For more advanced curl request, use the Guzzle library
dasherize ( type $str ) : type To dasherize HelloWorld = Hello-World
dateDifference ( $date1, $date2, $abs = true ) : Array(seconds,minutes,hours,days...) Calculate the date diff between 2 dates
excerpt ( string $text, integer $wordCount = 250 ) : string Will create an excerpt of the content. Will remove any html tags
filterDirtyWords ( $list, $hidden = "", $str = "" ) # CLEAN DIRTY WORD
formatDate ( $datetime, $format = "date" ) : To format a YYY-MM-DD HH:II:SS into a human readable
formatInvoice ( $n, $zeroPad = 9 ) ------------------------------------------------------------------------------
formatPhoneNumber ( $phone = '', $returnRaw = false, $trim = true, $convert = false )
formatTweets ( $status, $targetBlank = true, $linkMaxLen = 250 ) : String formatTweets
generatePathFromSequencedNumber ( $str, $paddingLength = 12 ) : string To generate a path sequence from a number if str is 546372 It will create a 3 level path 000/000/546
generateRandomString ( INT $strLen = 7, INT $minLen = 5, BOOL $randomLen = false, BOOL $noCloseSameChar = true, $addZeroOne = false ) : STRING generateRandomString() To create a random string with a specific length.
getAge ( Datetime $dob ) : integer Calculate an age
getArrayDotNotationValue ( array $Data, String $dotNotationKeys = "", mixed $emptyValue = "" ) : Mixed: Read data in array, based on dotNotationKeys
getDomain ( $url ) * Return the domain name of a url
getJsonLastError ( ) : Array Get json last error after json_decode()
getNonce ( integer $size = 32 ) : string To generate a nonce token
getPastDateRange ( $date = "" ) : Array(INT To generarate date in the past. Will return an Array(0=>start time,1=>end time) Can be used when making a date range query, and would like to get the stat and the end
multiArraySearch ( $needle, $haystack, $index_starter )
number_format_HumanReadable ( $number, $decimals ) : To format a number and return it as K,M,T
paginationGetMaxLimit ( integer $pageNumber = 1, inte $itemsPerPage ) : integer Get the max limit in a pagination
paginationGetMinLimit ( integer $pageNumber = 1, inte $itemsPerPage ) : integer Get the min limit in a pagination
paginationGetTotalPages ( integer $totalItems, integer $itemsPerPage ) : integer To get the total pages from set values in pagination
recursiveCopy ( $src, $dest ) : Copy file recursively
recursiveDelete ( strin $dir ) : boolean Delete file recursively
removeRepetitiveChar ( $string, $charToRemove = "", $max, $replacement = "" ) : To remove repetitive chars in a string that are close to each other
removeUrl ( $data )
seconds2Time ( $secs ) : string To convert seconds into time -> HH:MM:SS. It will ommit the hours if not available
setArrayToDotNotation ( type &$root, type $dotNotationKeys, type $value ) To set value in array with dot notation
strPossessive ( string $string ) : string To create a possesive.
stripHtmlComments ( string $content ) : string To strip html comments.
time2Seconds ( string $time ) : integer Convert a time HH:MM:SS to seconds
timeSince ( $time ) : string To calculate a time since the $timestamp and will return it into a human readable date, like 2 hours ago, 7 weeks ago created for twitter and statuses
toCurrency ( $digit ) : Format number to currency
toFriendlyUrl ( $O ) # To make an URL Friendly
toUnderscore ( type $str ) : string To convert camelized case to underscore
truncate ( $str, $max_chars = 3000, $force = 1 ) # May 27 2005
validEmail ( $email )
validIP ( $str )
validLogin ( string $str, integer $min = 4, integer $max = 64 ) : boolean Check if a login is valid
validPassword ( string $str, integer $min = 6, integer $max = 32 ) : boolean Check if a password is valid
validUrl ( $str )
validZipCode ( $zip )

비공개 메소드들

메소드 설명
timeSince_read ( $num, $word ) : To return a the human readable time since of self:timeSince

메소드 상세

CompressOutput() 공개 정적인 메소드

Will send the the header etc Good when sending a lot of JSON to the browser
public static CompressOutput ( $content, $print = true ) :
$content
$print
리턴

TimeZoneList() 공개 정적인 메소드

All the timezone list by region
public static TimeZoneList ( ) : Array
리턴 Array

arrayExtend() 공개 정적인 메소드

To extend an array with another array by merging the data and update them with new a
public static arrayExtend ( Array $a, Array $b ) : Array
$a Array - The original array
$b Array - The array to merge with
리턴 Array

arrayFlatten() 공개 메소드

To flatten multi dimensional array into a flat one. Also preserve the key
public arrayFlatten ( array $ar, Array $f = [] ) : mixed
$ar array
$f Array - am array to extend to
리턴 mixed Arr- boolean

arrayToDotNotation() 공개 정적인 메소드

Convert an array to dot notation
public static arrayToDotNotation ( type $Arr ) : type
$Arr type
리턴 type

array_merge_recursive_distinct() 공개 정적인 메소드

If the entry or the next value to be assigned is an array, then it automagically treats both arguments as an array. Numeric entries are appended, not replaced, but only if they are unique calling: result = array_merge_recursive_distinct(a1, a2, ... aN)
public static array_merge_recursive_distinct ( )

array_msort() 공개 정적인 메소드

Array Multi sort wi $arr2 = array_msort($arr1, array('name'=>array(SORT_DESC,SORT_REGULAR), 'cat'=>SORT_ASC));
public static array_msort ( $array, $cols ) : Array
$array
$cols
리턴 Array http://php.net/manual/en/function.array-multisort.php

calculateDistance() 공개 정적인 메소드

To calculate distance between to coordinaces
public static calculateDistance ( $lat1, $lon1, $lat2, $lon2, $unit = "M" ) :
$lat1
$lon1
$lat2
$lon2
$unit
리턴

camelize() 공개 정적인 메소드

Camelize
public static camelize ( type $string, type $pascalCase = false ) : type
$string type
$pascalCase type - if true = CamelCase, else camelCase
리턴 type

convertCm2In() 공개 정적인 메소드

Cm to inches
public static convertCm2In ( $val ) :
$val
리턴

convertCm2M() 공개 정적인 메소드

Cm to meters
public static convertCm2M ( $val ) :
$val
리턴

convertIn2Cm() 공개 정적인 메소드

inches to cm
public static convertIn2Cm ( $val ) :
$val
리턴

convertIn2Ft_human() 공개 정적인 메소드

Human inches value and convert it to a human readable
public static convertIn2Ft_human ( $val, $dumb = false ) :
$val
$dumb
리턴

convertM2Cm() 공개 정적인 메소드

Meters to cm
public static convertM2Cm ( $val ) :
$val
리턴

countWords() 공개 정적인 메소드

To count total words in a string
public static countWords ( $str )

createTagCloud() 공개 메소드

To create a tag cloud based on the tags provided
public createTagCloud ( array $Tags, string $Link = "", INT $cloud_spread, $sort = "count", string $title = "%tag%", boolean $sizeTags = false ) : String
$Tags array - array($tagName=>$tagCount)
$Link string - Link to connect to the tags
$cloud_spread INT - max tags to show
$sort
$title string - the title to enter in the link. Can be formatted with %tag% | %count% to add the tag and count respectively in the a href title
$sizeTags boolean - to allow multiple size of fonts
리턴 String LI

curlRequest() 공개 정적인 메소드

To make a simple curl request For more advanced curl request, use the Guzzle library
public static curlRequest ( string $url, mixed $params = [], string $method = "GET", array $curlOptions = [] ) : Array
$url string
$params mixed
$method string (GET | POST | DELETE | PUT)
$curlOptions array
리턴 Array [(string)response, (array)response_json, (array)headers]

dasherize() 공개 정적인 메소드

To dasherize HelloWorld = Hello-World
public static dasherize ( type $str ) : type
$str type
리턴 type

dateDifference() 공개 정적인 메소드

Calculate the date diff between 2 dates
public static dateDifference ( $date1, $date2, $abs = true ) : Array(seconds,minutes,hours,days...)
리턴 Array(seconds,minutes,hours,days...)

excerpt() 공개 정적인 메소드

Will create an excerpt of the content. Will remove any html tags
public static excerpt ( string $text, integer $wordCount = 250 ) : string
$text string
$wordCount integer
리턴 string plain text

filterDirtyWords() 공개 정적인 메소드

# CLEAN DIRTY WORD
public static filterDirtyWords ( $list, $hidden = "", $str = "" )

formatDate() 공개 정적인 메소드

To format a YYY-MM-DD HH:II:SS into a human readable
public static formatDate ( $datetime, $format = "date" ) :
$datetime
리턴

formatInvoice() 공개 정적인 메소드

------------------------------------------------------------------------------
public static formatInvoice ( $n, $zeroPad = 9 )

formatPhoneNumber() 공개 정적인 메소드

public static formatPhoneNumber ( $phone = '', $returnRaw = false, $trim = true, $convert = false )

formatTweets() 공개 정적인 메소드

To convert links on a twitter status to a clickable url. Also convert @ to follow link, and # to search
저자: : Mardix - http://mardix.wordpress.com, http://www.givemebeats.net
public static formatTweets ( $status, $targetBlank = true, $linkMaxLen = 250 ) : String
리턴 String

generatePathFromSequencedNumber() 공개 정적인 메소드

To generate a path sequence from a number if str is 546372 It will create a 3 level path 000/000/546
public static generatePathFromSequencedNumber ( $str, $paddingLength = 12 ) : string
리턴 string new path

generateRandomString() 공개 정적인 메소드

Can also generate a random number by providing the minLen and randomLen=true
저자: : Mardix
public static generateRandomString ( INT $strLen = 7, INT $minLen = 5, BOOL $randomLen = false, BOOL $noCloseSameChar = true, $addZeroOne = false ) : STRING
$strLen INT : the maximum length of the new string
$minLen INT : The minimum length to generate the $randomLen
$randomLen BOOL : to generate random length between $strLen and $minLen
$noCloseSameChar BOOL : If you don't want two same chars to be close to each other
$addZeroOne
리턴 STRING : a new length of string

getAge() 공개 정적인 메소드

Calculate an age
public static getAge ( Datetime $dob ) : integer
$dob Datetime
리턴 integer

getArrayDotNotationValue() 공개 정적인 메소드

Read data in array, based on dotNotationKeys
public static getArrayDotNotationValue ( array $Data, String $dotNotationKeys = "", mixed $emptyValue = "" ) : Mixed:
$Data array
$dotNotationKeys String - the dot notation, i.e, "key.subkey.subsubkey"
$emptyValue mixed - A value to return if dotNotArg doesnt find any match
리턴 Mixed:

getDomain() 공개 정적인 메소드

* Return the domain name of a url
public static getDomain ( $url )

getJsonLastError() 공개 정적인 메소드

Get json last error after json_decode()
public static getJsonLastError ( ) : Array
리턴 Array if error or FALSE

getNonce() 공개 정적인 메소드

To generate a nonce token
public static getNonce ( integer $size = 32 ) : string
$size integer - 32bytes = 256bit
리턴 string

getPastDateRange() 공개 정적인 메소드

To generarate date in the past. Will return an Array(0=>start time,1=>end time) Can be used when making a date range query, and would like to get the stat and the end
public static getPastDateRange ( $date = "" ) : Array(INT
리턴 Array(INT

multiArraySearch() 공개 정적인 메소드

public static multiArraySearch ( $needle, $haystack, $index_starter )

number_format_HumanReadable() 공개 정적인 메소드

To format a number and return it as K,M,T
public static number_format_HumanReadable ( $number, $decimals ) :
$number
$decimals
리턴

paginationGetMaxLimit() 공개 정적인 메소드

Get the max limit in a pagination
public static paginationGetMaxLimit ( integer $pageNumber = 1, inte $itemsPerPage ) : integer
$pageNumber integer
$itemsPerPage inte
리턴 integer

paginationGetMinLimit() 공개 정적인 메소드

Get the min limit in a pagination
public static paginationGetMinLimit ( integer $pageNumber = 1, inte $itemsPerPage ) : integer
$pageNumber integer
$itemsPerPage inte
리턴 integer

paginationGetTotalPages() 공개 정적인 메소드

To get the total pages from set values in pagination
public static paginationGetTotalPages ( integer $totalItems, integer $itemsPerPage ) : integer
$totalItems integer
$itemsPerPage integer
리턴 integer

recursiveCopy() 공개 정적인 메소드

Copy file recursively
public static recursiveCopy ( $src, $dest ) :
리턴

recursiveDelete() 공개 정적인 메소드

Delete file recursively
public static recursiveDelete ( strin $dir ) : boolean
$dir strin
리턴 boolean

removeRepetitiveChar() 공개 정적인 메소드

To remove repetitive chars in a string that are close to each other
public static removeRepetitiveChar ( $string, $charToRemove = "", $max, $replacement = "" ) :
$string
$charToRemove
$max
$replacement
리턴

removeUrl() 공개 정적인 메소드

public static removeUrl ( $data )

seconds2Time() 공개 정적인 메소드

To convert seconds into time -> HH:MM:SS. It will ommit the hours if not available
public static seconds2Time ( $secs ) : string
리턴 string HH:MM:SS

setArrayToDotNotation() 공개 정적인 메소드

To set value in array with dot notation
public static setArrayToDotNotation ( type &$root, type $dotNotationKeys, type $value )
$root type
$dotNotationKeys type
$value type

strPossessive() 공개 정적인 메소드

echo strPossessive("Chris"); //returns Chris' echo strPossessive("David"); //returns David's
public static strPossessive ( string $string ) : string
$string string
리턴 string

stripHtmlComments() 공개 정적인 메소드

But will leave conditionals comments such as
public static stripHtmlComments ( string $content ) : string
$content string
리턴 string

time2Seconds() 공개 정적인 메소드

Convert a time HH:MM:SS to seconds
public static time2Seconds ( string $time ) : integer
$time string -> HH:MM:SS
리턴 integer

timeSince() 공개 정적인 메소드

To calculate a time since the $timestamp and will return it into a human readable date, like 2 hours ago, 7 weeks ago created for twitter and statuses
public static timeSince ( $time ) : string
리턴 string : the time since date

toCurrency() 공개 정적인 메소드

Format number to currency
public static toCurrency ( $digit ) :
$digit
리턴

toFriendlyUrl() 공개 정적인 메소드

# To make an URL Friendly
public static toFriendlyUrl ( $O )

toUnderscore() 공개 정적인 메소드

To convert camelized case to underscore
public static toUnderscore ( type $str ) : string
$str type - ie: HelloWorld = Hello_World
리턴 string

truncate() 공개 정적인 메소드

# May 27 2005
public static truncate ( $str, $max_chars = 3000, $force = 1 )

validEmail() 공개 정적인 메소드

public static validEmail ( $email )

validIP() 공개 정적인 메소드

public static validIP ( $str )

validLogin() 공개 정적인 메소드

Check if a login is valid
public static validLogin ( string $str, integer $min = 4, integer $max = 64 ) : boolean
$str string
$min integer
$max integer
리턴 boolean

validPassword() 공개 정적인 메소드

Check if a password is valid
public static validPassword ( string $str, integer $min = 6, integer $max = 32 ) : boolean
$str string
$min integer
$max integer
리턴 boolean

validUrl() 공개 정적인 메소드

public static validUrl ( $str )

validZipCode() 공개 정적인 메소드

public static validZipCode ( $zip )