PHP 클래스 JBZoo\Utils\Str

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

공개 프로퍼티들

프로퍼티 타입 설명
$encoding string Default charset is UTF-8

공개 메소드들

메소드 설명
clean ( string $string, boolean $toLower = false, boolean $addslashes = false ) : string Make string safe - Remove UTF-8 chars - Remove all tags - Trim - Addslashes (opt) - To lower (opt)
esc ( string $string ) : string Escape UTF-8 strings
escXml ( $string ) : mixed Escape string before save it as xml content
getClassName ( mixed $object, boolean $toLower = false ) : mixed | string Get class name without namespace
htmlEnt ( string $string, boolean $encodedEntities = false ) : string Convert >, <, ', " and & to html entities, but preserves entities that are already encoded.
inc ( string $string, string $style = 'default', integer $next ) : string Increments a trailing number in a string.
ipos ( string $haystack, string $needle, integer $offset ) : integer Finds position of first occurrence of a string within another, case insensitive
isEnd ( string $haystack, string $needle, boolean $caseSensitive = false ) : boolean Checks if the $haystack ends with the text in the $needle. Case sensitive.
isMBString ( ) : boolean Check is mbstring loaded
isOverload ( ) : integer Check is mbstring oeverload standard functions
isStart ( string $haystack, string $needle, boolean $caseSensitive = false ) : boolean Checks if the $haystack starts with the text in the $needle.
istr ( string $haystack, string $needle, boolean $beforeNeedle = false ) : string Finds first occurrence of a string within another, case insensitive
len ( $string ) : integer Get string length
like ( string $pattern, string $string, boolean $caseSensitive = true ) : boolean Check if a given string matches a given pattern.
limitChars ( string $string, integer $limit = 100, string $append = '...' ) : string Truncate the string to given length of characters.
limitWords ( string $string, integer $limit = 100, string $append = '...' ) : string Truncate the string to given length of words.
low ( string $string ) : string Make a string lowercase
parseLines ( string $text, boolean $toAssoc = true ) : array Parse text by lines
pos ( string $haystack, string $needle, integer $offset ) : integer Find position of first occurrence of string in a string
random ( integer $length = 10, boolean $isReadable = true ) : string Generate ridable random string
rchr ( string $haystack, string $needle, boolean $part = null ) : string Finds the last occurrence of a character in a string within another
rpos ( string $haystack, string $needle, integer $offset ) : integer Find position of last occurrence of a string in a string
slug ( string $text = '', boolean $isCache = false ) : string Converts any accent characters to their equivalent normal characters
splitCamelCase ( string $input, string $separator = '_', boolean $toLower = true ) : string Convert camel case to human readable format
splitSql ( string $sql ) : array Splits a string of multiple queries into an array of individual queries.
stripSpace ( string $string ) : string Strip all witespaces from the given string.
strstr ( string $haystack, string $needle, boolean $beforeNeedle = false ) : string Finds first occurrence of a string within another
sub ( string $string, integer $start, integer $length ) : string Get part of string
subCount ( string $haystack, string $needle ) : integer Count the number of substring occurrences
testName2Human ( string $input ) : mixed | string Convert test name to human readable string
trim ( string $value, boolean $extendMode = false ) : string Trim whitespaces and other special chars
truncateSafe ( string $string, integer $length, string $append = '...' ) : string Truncate a string to a specified length without cutting a word off.
unique ( string $prefix = 'unique' ) : string Get unique string
up ( string $string ) : string Make a string uppercase
uuid ( ) : string Generates a universally unique identifier (UUID v4) according to RFC 4122 Version 4 UUIDs are pseudo-random!
zeroPad ( integer $number, integer $length ) : string Pads a given string with zeroes on the left.

메소드 상세

clean() 공개 정적인 메소드

Make string safe - Remove UTF-8 chars - Remove all tags - Trim - Addslashes (opt) - To lower (opt)
public static clean ( string $string, boolean $toLower = false, boolean $addslashes = false ) : string
$string string
$toLower boolean
$addslashes boolean
리턴 string

esc() 공개 정적인 메소드

Escape UTF-8 strings
public static esc ( string $string ) : string
$string string
리턴 string

escXml() 공개 정적인 메소드

Escape string before save it as xml content
public static escXml ( $string ) : mixed
$string
리턴 mixed

getClassName() 공개 정적인 메소드

Get class name without namespace
public static getClassName ( mixed $object, boolean $toLower = false ) : mixed | string
$object mixed
$toLower boolean
리턴 mixed | string

htmlEnt() 공개 정적인 메소드

Convert >, <, ', " and & to html entities, but preserves entities that are already encoded.
public static htmlEnt ( string $string, boolean $encodedEntities = false ) : string
$string string The text to be converted
$encodedEntities boolean
리턴 string

inc() 공개 정적인 메소드

Used to easily create distinct labels when copying objects. The method has the following styles: - default: "Label" becomes "Label (2)" - dash: "Label" becomes "Label-2"
public static inc ( string $string, string $style = 'default', integer $next ) : string
$string string The source string.
$style string The the style (default|dash).
$next integer If supplied, this number is used for the copy, otherwise it is the 'next' number.
리턴 string

ipos() 공개 정적인 메소드

Finds position of first occurrence of a string within another, case insensitive
public static ipos ( string $haystack, string $needle, integer $offset ) : integer
$haystack string
$needle string
$offset integer
리턴 integer

isEnd() 공개 정적인 메소드

Checks if the $haystack ends with the text in the $needle. Case sensitive.
public static isEnd ( string $haystack, string $needle, boolean $caseSensitive = false ) : boolean
$haystack string
$needle string
$caseSensitive boolean
리턴 boolean

isMBString() 공개 정적인 메소드

Check is mbstring loaded
public static isMBString ( ) : boolean
리턴 boolean

isOverload() 공개 정적인 메소드

Check is mbstring oeverload standard functions
public static isOverload ( ) : integer
리턴 integer

isStart() 공개 정적인 메소드

Checks if the $haystack starts with the text in the $needle.
public static isStart ( string $haystack, string $needle, boolean $caseSensitive = false ) : boolean
$haystack string
$needle string
$caseSensitive boolean
리턴 boolean

istr() 공개 정적인 메소드

Finds first occurrence of a string within another, case insensitive
public static istr ( string $haystack, string $needle, boolean $beforeNeedle = false ) : string
$haystack string
$needle string
$beforeNeedle boolean
리턴 string

len() 공개 정적인 메소드

Get string length
public static len ( $string ) : integer
$string
리턴 integer

like() 공개 정적인 메소드

Check if a given string matches a given pattern.
public static like ( string $pattern, string $string, boolean $caseSensitive = true ) : boolean
$pattern string Parttern of string exptected
$string string String that need to be matched
$caseSensitive boolean
리턴 boolean

limitChars() 공개 정적인 메소드

Truncate the string to given length of characters.
public static limitChars ( string $string, integer $limit = 100, string $append = '...' ) : string
$string string The variable to truncate
$limit integer The length to truncate the string to
$append string Text to append to the string IF it gets truncated, defaults to '...'
리턴 string

limitWords() 공개 정적인 메소드

Truncate the string to given length of words.
public static limitWords ( string $string, integer $limit = 100, string $append = '...' ) : string
$string string
$limit integer
$append string
리턴 string

low() 공개 정적인 메소드

Make a string lowercase
public static low ( string $string ) : string
$string string
리턴 string

parseLines() 공개 정적인 메소드

Parse text by lines
public static parseLines ( string $text, boolean $toAssoc = true ) : array
$text string
$toAssoc boolean
리턴 array

pos() 공개 정적인 메소드

Find position of first occurrence of string in a string
public static pos ( string $haystack, string $needle, integer $offset ) : integer
$haystack string
$needle string
$offset integer
리턴 integer

random() 공개 정적인 메소드

Generate ridable random string
public static random ( integer $length = 10, boolean $isReadable = true ) : string
$length integer
$isReadable boolean
리턴 string

rchr() 공개 정적인 메소드

Finds the last occurrence of a character in a string within another
public static rchr ( string $haystack, string $needle, boolean $part = null ) : string
$haystack string
$needle string
$part boolean
리턴 string

rpos() 공개 정적인 메소드

Find position of last occurrence of a string in a string
public static rpos ( string $haystack, string $needle, integer $offset ) : integer
$haystack string
$needle string
$offset integer
리턴 integer

slug() 공개 정적인 메소드

Converts any accent characters to their equivalent normal characters
public static slug ( string $text = '', boolean $isCache = false ) : string
$text string
$isCache boolean
리턴 string

splitCamelCase() 공개 정적인 메소드

Convert camel case to human readable format
public static splitCamelCase ( string $input, string $separator = '_', boolean $toLower = true ) : string
$input string
$separator string
$toLower boolean
리턴 string

splitSql() 공개 정적인 메소드

Single line or line end comments and multi line comments are stripped off.
public static splitSql ( string $sql ) : array
$sql string Input SQL string with which to split into individual queries.
리턴 array

stripSpace() 공개 정적인 메소드

Strip all witespaces from the given string.
public static stripSpace ( string $string ) : string
$string string The string to strip
리턴 string

strstr() 공개 정적인 메소드

Finds first occurrence of a string within another
public static strstr ( string $haystack, string $needle, boolean $beforeNeedle = false ) : string
$haystack string
$needle string
$beforeNeedle boolean
리턴 string

sub() 공개 정적인 메소드

Get part of string
public static sub ( string $string, integer $start, integer $length ) : string
$string string
$start integer
$length integer
리턴 string

subCount() 공개 정적인 메소드

Count the number of substring occurrences
public static subCount ( string $haystack, string $needle ) : integer
$haystack string
$needle string
리턴 integer

testName2Human() 공개 정적인 메소드

Convert test name to human readable string
public static testName2Human ( string $input ) : mixed | string
$input string
리턴 mixed | string

trim() 공개 정적인 메소드

Trim whitespaces and other special chars
public static trim ( string $value, boolean $extendMode = false ) : string
$value string
$extendMode boolean
리턴 string

truncateSafe() 공개 정적인 메소드

Truncate a string to a specified length without cutting a word off.
public static truncateSafe ( string $string, integer $length, string $append = '...' ) : string
$string string The string to truncate
$length integer The length to truncate the string to
$append string Text to append to the string IF it gets truncated, defaults to '...'
리턴 string

unique() 공개 정적인 메소드

Get unique string
public static unique ( string $prefix = 'unique' ) : string
$prefix string
리턴 string

up() 공개 정적인 메소드

Make a string uppercase
public static up ( string $string ) : string
$string string
리턴 string

uuid() 공개 정적인 메소드

Returns Version 4 UUID format: xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx where x is any random hex digit and Y is a random choice from 8, 9, a, or b.
또한 보기: http://stackoverflow.com/questions/2040240/php-function-to-generate-v4-uuid
public static uuid ( ) : string
리턴 string

zeroPad() 공개 정적인 메소드

Pads a given string with zeroes on the left.
public static zeroPad ( integer $number, integer $length ) : string
$number integer The number to pad
$length integer The total length of the desired string
리턴 string

프로퍼티 상세

$encoding 공개적으로 정적으로 프로퍼티

Default charset is UTF-8
public static string $encoding
리턴 string