idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
47,600
public function belongsTo ( string $ alias , string $ entity ) : Relation { return $ this -> belongs_to [ $ entity ] = new Relation ( $ alias , $ this -> full_name , $ entity ) ; }
Add a belongs to relationship
47,601
public function associates ( string $ alias_join , string $ alias_left , string $ entity_left , string $ alias_right , string $ entity_right ) : ManyToMany { return $ this -> many_to_many [ ] = new ManyToMany ( $ alias_join , $ alias_left , $ this -> full_name , $ entity_left , $ alias_right , $ entity_right ) ; }
Adds a has many through relationship to the left and right Entity s through this Entity
47,602
public function virtual ( string $ name , string $ type , callable $ callback ) : void { $ this -> virtuals [ $ name ] = new VirtualField ( $ name , $ type , $ callback ) ; }
Adds a virtual field to the Entity . The callable will be executed whenever the virtual field is accessed and passed the Entity .
47,603
public function setUserId ( int $ id ) { if ( $ id !== $ this -> userId ) { if ( $ this -> user !== null && $ this -> user -> getId ( ) !== $ id ) { $ this -> user = null ; } ; $ this -> userId = $ id ; } return $ this ; }
Set associated userId
47,604
protected function _replaceTokens ( $ input , $ source , $ tokenStart , $ tokenEnd , $ default = null ) { $ input = $ this -> _normalizeString ( $ input ) ; $ default = $ default === null ? '' : $ this -> _normalizeString ( $ default ) ; $ regexDelimiter = '/' ; $ tokenStart = $ this -> _quoteRegex ( $ tokenStart , $ r...
Replaces all tokens in a string with corresponding values .
47,605
public function createClass ( string $ name , string $ location , string $ extends = "" ) : bool { $ namespace = trim ( $ this -> getNameSpace ( $ name ) ) ; $ name = trim ( $ this -> getClassName ( $ name ) ) ; $ className = $ name ; if ( $ extends !== "" ) { $ className .= " extends {$extends}" ; } if ( $ namespace !...
Create a class
47,606
public function getNameSpace ( string $ name ) : string { $ segs = [ ] ; $ name = str_replace ( "/" , "\\" , $ name ) ; $ namespace = explode ( "\\" , $ name ) ; array_pop ( $ namespace ) ; array_walk ( $ namespace , function ( & $ value ) { $ value = $ this -> removeNoneAlpherNumeric ( $ value ) ; } ) ; return implode...
Work out name space of the class
47,607
public function getClassName ( string $ name ) : string { $ name = str_replace ( "/" , "\\" , $ name ) ; $ name = explode ( "\\" , $ name ) ; $ name = array_pop ( $ name ) ; $ name = $ this -> removeNoneAlpherNumeric ( $ name ) ; return $ name ; }
Work out the class name from a namespace string
47,608
public function Equals ( $ item1 , $ item2 ) { if ( $ item1 === null && $ item2 !== null ) { return false ; } else if ( $ item1 !== null && $ item2 === null ) { return false ; } else if ( $ item1 === null && $ item2 === null ) { return true ; } return $ item1 -> Equals ( $ item2 ) ; }
Compares the items
47,609
private function convertDbToApi ( $ db ) { $ result = new AResponse ( ) ; if ( $ db ) { $ custId = $ db [ QBGetCustomer :: A_ID ] ; $ email = $ db [ QBGetCustomer :: A_EMAIL ] ; $ nameFirst = $ db [ QBGetCustomer :: A_NAME_FIRST ] ; $ nameLast = $ db [ QBGetCustomer :: A_NAME_LAST ] ; $ mlmId = $ db [ QBGetCustomer :: ...
Convert database query result set to response object .
47,610
public function getMappingFiles ( ) : array { $ mappingPaths = [ ] ; foreach ( $ this -> paths as $ mappingPath ) { if ( \ is_dir ( $ mappingPath ) ) { $ mappingPaths [ ] = $ this -> getFilesFromDirectory ( $ mappingPath ) ; } elseif ( \ is_file ( $ mappingPath ) ) { $ mappingPaths [ ] = [ $ mappingPath ] ; } else { th...
Get mapping files .
47,611
protected function getFilesFromDirectory ( string $ mappingDirectory ) : array { $ mappingPaths = [ ] ; $ filePattern = \ sprintf ( '/^.+\.(%s)$/i' , \ implode ( '|' , $ this -> extensions ) ) ; $ recursiveIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ mappingDirectory ) ) ; $ regexIt...
Get mapping files from directory .
47,612
public static function createInstance ( $ driver , $ options ) { if ( ! in_array ( $ driver , self :: $ _validDrivers ) ) { throw new \ Exception ( "Driver '{$driver}' not implemented" ) ; } $ class = __NAMESPACE__ . '\\Driver\\' . $ driver ; $ driver = new $ class ; $ driver -> setOptions ( $ options ) ; return new St...
Create new instance of G4 \ Storage \ Storage
47,613
public function merge ( ClassMetadata $ object ) { $ properties = $ this -> properties ; $ methods = $ this -> methods ; foreach ( $ object -> getProperties ( ) as $ property ) { $ properties [ $ property -> getName ( ) ] = $ property ; } foreach ( $ object -> getMethods ( ) as $ method ) { $ methods [ $ method -> getN...
Merge the ClassMetadata of the object with the current ClassMetadata into a new object .
47,614
private function mapQueryToActionParameters ( RouteEndpoint $ route , RequestInterface $ request ) : array { $ reflection = new ReflectionClass ( $ route -> getFullyQualifiedName ( ) ) ; $ method = $ reflection -> getMethod ( $ route -> getAction ( true ) ) ; $ query = $ request -> getQuery ( ) ; $ mapper = [ ] ; forea...
Maps all the query parameters to the controller action parameters
47,615
protected function setThumbnailer ( Thumbnailer $ thumbnailer ) { if ( ! $ thumbnailer instanceof Thumbnailer ) { throw new \ Exception ( 'The thumbnailer service given is not instance of Thumbnailer\Thumbnailer\Thumbnailer' ) ; } $ this -> options [ 'thumbnailer' ] = $ thumbnailer ; return $ this ; }
Set the thumbnailer given with the options
47,616
public function get ( $ key ) { if ( array_key_exists ( $ key , $ this -> _map ) ) { return $ this -> _map [ $ key ] ; } return null ; }
Get attribute from web context .
47,617
public function query ( $ name , $ val = null ) { return isset ( $ this -> _queries [ $ name ] ) ? $ this -> _queries [ $ name ] : $ val ; }
Get query string from url
47,618
public function queries ( array $ names , $ default = null ) { $ var = [ ] ; foreach ( $ names as $ in ) { $ var [ $ in ] = isset ( $ this -> _queries [ $ in ] ) ? $ this -> _queries [ $ in ] : $ default ; } return $ var ; }
Getting querie from url parameters
47,619
public function only ( array $ names , $ default = null ) { $ var = [ ] ; foreach ( $ names as $ in ) { $ var [ $ in ] = isset ( $ this -> _requests [ $ in ] ) ? $ this -> _requests [ $ in ] : $ default ; } return $ var ; }
Getting segments of inputs
47,620
public function except ( array $ name ) { $ var = [ ] ; foreach ( $ this -> _requests as $ k => $ v ) { if ( ! in_array ( $ k , $ name ) ) { $ var [ $ k ] = $ v ; } } return $ var ; }
Get data input except some
47,621
public function hasInputs ( array $ names ) { foreach ( $ names as $ name ) { if ( ! $ this -> has ( $ name ) ) return false ; } return true ; }
Check if inputs are received
47,622
public function hasQueries ( array $ names ) { foreach ( $ names as $ name ) { if ( ! $ this -> hasQuery ( $ name ) ) return false ; } return true ; }
Check if queries exists
47,623
public function url ( $ component = - 1 ) { $ active_url = URL :: here ( ) ; if ( $ component > - 1 ) { return parse_url ( $ active_url , $ component ) ; } return $ active_url ; }
Get request URL
47,624
public function header ( $ header ) { foreach ( $ this -> _headers as $ k => $ v ) { if ( ! strcasecmp ( $ k , $ header ) ) { return $ v ; } } return null ; }
Get request header value
47,625
public function getPageResult ( $ url , $ attributes = [ ] ) { $ request = new Request ( ) ; $ request -> setService ( self :: SERVICE_PAGE ) ; $ request -> setParam ( 'url' , $ url ) ; $ request -> setAttributes ( $ attributes ) ; return $ this -> execute ( $ request ) ; }
Get details for a page
47,626
public function execute ( RequestInterface $ request ) { $ httpRequest = $ this -> httpRequestBuilder -> build ( $ request ) ; $ httpResponse = $ this -> transport -> execute ( $ httpRequest ) ; return $ this -> resultBuilderEngine -> build ( $ request , $ httpResponse ) ; }
Execute a OneHydra request and return the result
47,627
public static function targetGet ( $ needle , array $ haystack , $ default = null ) { if ( $ needle === null ) { return $ haystack ; } $ parts = preg_split ( '/(?<!\\\\)\./' , $ needle ) ; foreach ( $ parts as $ part ) { $ key = str_replace ( '\\.' , '.' , $ part ) ; if ( is_array ( $ haystack ) === false || array_key_...
Get an value from an array via a dotted notation
47,628
public static function targetSet ( $ needle , $ value , array $ haystack = array ( ) ) { $ keys = explode ( '.' , $ needle ) ; $ loop = & $ haystack ; foreach ( $ keys as $ key ) { if ( is_array ( $ loop ) === false ) { $ loop = array ( ) ; } if ( array_key_exists ( $ key , $ loop ) === false ) { $ loop [ $ key ] = arr...
Set an value on a multi dimensional array via a dotted string notation
47,629
public function __isset ( $ helper ) { if ( isset ( $ this -> _helpers [ $ helper ] ) ) { $ isset = true ; } else { $ isset = ! is_null ( $ this -> _getHelper ( $ helper ) ) ; } return $ isset ; }
Is helper presents ?
47,630
private function _getHelper ( $ helper ) { $ instance = null ; foreach ( $ this -> _prefixes as $ prefix ) { $ className = $ prefix . "\\" . $ helper ; if ( Loader :: loadClass ( $ className ) ) { if ( is_subclass_of ( $ className , __NAMESPACE__ . "\\Helper_Interface" ) ) { $ instance = new $ className ( ) ; $ instanc...
Creates a new helper s instance
47,631
public function prependPrefix ( $ prefix ) { $ this -> deletePrefix ( $ prefix ) ; $ prepend = array ( $ prefix => $ prefix ) ; $ this -> _prefixes = array_merge ( $ prepend , $ this -> _prefixes ) ; }
Prepend namespace - prefix
47,632
public static function fromString ( $ string ) { $ matched = preg_match ( "/[^0-9a-fA-F]+/" , $ string , $ matches ) ; if ( $ matched || strlen ( $ string ) % 2 != 0 ) { throw XPath2Exception :: withErrorCodeAndParams ( "FORG0001" , Resources :: InvalidFormat , array ( $ string , "xs:hexBinary" ) ) ; } $ binary = hex2b...
Convert a string representation of a hex value to is binary version and create a HexBinaryValue instance
47,633
public function classUsesParentsTrait ( $ className ) { if ( is_object ( $ className ) ) { $ className = get_class ( $ className ) ; } if ( false === isset ( $ this -> classUsingParentsTrait [ $ className ] ) ) { $ this -> classUsingParentsTrait [ $ className ] = $ this -> checkClassUsesParentsTrait ( $ className ) ; }...
Will check and store the class names which use the trait ParentsTrait .
47,634
protected function checkClassUsesParentsTrait ( $ className ) { $ flag = false ; $ classes = array_merge ( [ $ className ] , class_parents ( $ className ) ) ; foreach ( $ classes as $ class ) { $ traits = class_uses ( $ class ) ; $ flag = $ flag || ( true === isset ( $ traits [ ParentsTrait :: class ] ) ) ; } return $ ...
Will check if the given class name uses the trait ParentsTrait .
47,635
function ask ( $ question , array $ answers ) { $ optstr = implode ( "|" , $ answers ) ; do { $ this -> printf ( "$question [$optstr] " ) ; $ answer = $ this -> fgets ( ) ; } while ( ! in_array ( $ answer , $ answers ) ) ; return $ answer ; }
Shorthand for retrieving confirmation from console . Common console task for input .
47,636
public static function plural ( string $ word ) : string { if ( in_array ( $ word , Inflector :: $ _uncontable ) ) { return $ word ; } if ( isset ( Inflector :: $ _plural [ "irregular" ] [ $ word ] ) ) { return Inflector :: $ _plural [ "irregular" ] [ $ word ] ; } foreach ( Inflector :: $ _plural [ "uninflected" ] as $...
Returns the plural form of the word .
47,637
public static function singular ( string $ word ) : string { if ( in_array ( $ word , Inflector :: $ _uncontable ) ) { return $ word ; } if ( isset ( Inflector :: $ _singular [ "irregular" ] [ $ word ] ) ) { return Inflector :: $ _singular [ "irregular" ] [ $ word ] ; } foreach ( Inflector :: $ _singular [ "uninflected...
Returns the singular form of the word .
47,638
public function addCharacters ( $ chars ) { if ( WF :: is_array_like ( $ chars ) ) { foreach ( $ chars as $ char ) { if ( ! is_string ( $ char ) ) throw new InvalidArgumentException ( "Invalid type: " . WF :: str ( $ chars ) ) ; $ this -> characters [ $ char ] = true ; } } elseif ( is_string ( $ chars ) ) { for ( $ i =...
Add one or more characters to the list of eligible characters
47,639
public function generatePassword ( int $ length = 8 ) { if ( $ length <= 0 ) throw new DomainException ( "Cannot generate zero-length passwords" ) ; if ( empty ( $ this -> characters ) ) throw new UnderflowException ( "First add characters used to generate the password" ) ; $ chars = implode ( '' , array_keys ( $ this ...
Generate a password of the specified length
47,640
public function loadDictionary ( string $ filename , $ append = false , $ regexp = "/^[a-z]{4,6}$/" ) { if ( ! file_exists ( $ filename ) || ! is_readable ( $ filename ) ) { $ orig = $ filename ; $ filename = "/usr/share/dict/" . $ filename ; if ( ! file_exists ( $ filename ) ) throw new IOException ( "Cannot open file...
Load a dictionary file for passphrase generation
47,641
public function generatePassphrase ( $ num_words = 4 ) { if ( count ( $ this -> dictionary ) < $ num_words ) { throw new UnderflowException ( "Not enough words loaded to generate a passphrase of $num_words words" ) ; } $ words = array ( ) ; $ attempt = 0 ; while ( count ( $ words ) < $ num_words ) { ++ $ attempt ; $ s ...
Generate a passphrase of the specified amount of words
47,642
protected function normalizeMappingSources ( array $ mappingSources ) : array { return \ array_map ( function ( $ mappingSource ) : array { if ( ! \ is_array ( $ mappingSource ) ) { $ mappingSource = [ 'type' => DriverFactoryInterface :: DRIVER_ANNOTATION , 'path' => $ mappingSource , ] ; } return $ mappingSource ; } ,...
Normalize mapping sources format .
47,643
function RenderScript ( ) { $ templateFile = Path :: RemoveExtension ( $ this -> TemplateFile ( ) ) ; $ scriptFile = Path :: AddExtension ( $ templateFile , 'Script' ) ; ob_start ( ) ; require Path :: AddExtension ( $ scriptFile , 'phtml' ) ; return ob_get_clean ( ) ; }
Renderst necessary javascript
47,644
public function Check ( $ data ) { $ value = $ data [ $ this -> prefix . 'Page' ] ; return $ this -> pageField -> Check ( $ value ) ; }
Check the selector
47,645
public function Save ( PageUrl $ pageUrl = null ) { $ exists = $ pageUrl && $ pageUrl -> Exists ( ) ; $ page = $ this -> Value ( 'Page' ) ? Page :: Schema ( ) -> ByID ( $ this -> Value ( 'Page' ) ) : null ; if ( ! $ page ) { if ( $ exists ) { $ pageUrl -> Delete ( ) ; } return null ; } if ( ! $ exists ) { $ pageUrl = n...
Saves the page url and returns it
47,646
private function SaveParams ( PageUrl $ pageUrl ) { $ this -> ClearParams ( $ pageUrl ) ; $ params = $ this -> serializer -> LinesToArray ( $ this -> Value ( 'Params' ) ) ; $ prev = null ; foreach ( $ params as $ name => $ value ) { $ param = new PageUrlParameter ( ) ; $ param -> SetPageUrl ( $ pageUrl ) ; $ param -> S...
Saves the page paramters after the page url is saved
47,647
private function Value ( $ name ) { $ value = Request :: PostData ( $ this -> prefix . $ name ) ; return Str :: Trim ( $ value ) ; }
Gets the value by pure name
47,648
private function ClearParams ( PageUrl $ pageUrl ) { $ sql = Access :: SqlBuilder ( ) ; $ tblParams = PageUrlParameter :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblParams -> Field ( 'PageUrl' ) , $ sql -> Value ( $ pageUrl -> GetID ( ) ) ) ; PageUrlParameter :: Schema ( ) -> Delete ( $ where ) ; }
Clears the parameters of the page url
47,649
public function append ( string $ postfix ) : Utility { return new static ( $ this -> string . new static ( $ postfix , $ this -> encoding ) , $ this -> encoding ) ; }
Append the string with a given value
47,650
public function at ( int $ position ) : Utility { if ( $ position < 0 ) { return new static ( '' , $ this -> encoding ) ; } return $ this -> substring ( $ position , 1 ) ; }
Get the character at a specific index
47,651
public function clean ( string $ allowedTags = null ) : Utility { $ string = strip_tags ( trim ( $ this -> string ) , $ allowedTags ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove tags and trim the string
47,652
public function containsAll ( $ contains , int $ offset = 0 ) : bool { if ( empty ( $ contains ) ) { return false ; } $ parameters = $ this -> parameters ( $ contains ) ; if ( $ offset > $ this -> length ( ) ) { return false ; } foreach ( $ parameters as $ needle ) { if ( strpos ( $ this -> string , $ needle -> value (...
Check if a string contains all of the given values
47,653
public function explode ( $ delimiter , $ limit = PHP_INT_MAX ) : array { return array_slice ( array_map ( 'trim' , array_filter ( explode ( $ delimiter , $ this -> string , $ limit ) ) ) , 0 ) ; }
Explode the string on a given
47,654
public function first ( int $ count ) : Utility { if ( $ count < 0 ) { return new static ( '' , $ this -> encoding ) ; } return $ this -> substring ( 0 , $ count ) ; }
Get the first x characters from the string
47,655
public function format ( ... $ replacements ) : Utility { $ string = $ this -> string ; foreach ( $ replacements as $ index => $ value ) { if ( ! is_scalar ( $ value ) || ( is_object ( $ value ) && ! method_exists ( $ value , '__toString' ) ) ) { $ type = is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ valu...
Inserts the given values into the chronological placeholders
47,656
public function isFalse ( ) : bool { return ( in_array ( $ this -> string , [ '' ] ) || ( false === filter_var ( $ this -> string , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ) ) ; }
Check if a given value can be perceived as false . Will only return false if the value looks false - y by being a value of false 0 no off
47,657
public function isTrue ( ) : bool { return ( in_array ( $ this -> string , [ 'ok' ] ) || ( true === filter_var ( $ this -> string , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ) ) ; }
Check if a given value can be perceived as true Will on return true if the value looks true - y true 1 yes on ok
47,658
public function limit ( int $ length ) { $ string = $ this -> string ; if ( $ this -> length ( ) > $ length ) { $ string = substr ( $ string , 0 , $ length ) ; } return new static ( $ string , $ this -> encoding ) ; }
Limit the length of the string to a given value
47,659
public function minimise ( ) : Utility { $ replace = [ '/\>[^\S ]+/s' => '>' , '/[^\S ]+\</s' => '<' , '/([\t ])+/s' => ' ' , '/^([\t ])+/m' => '' , '/([\t ])+$/m' => '' , '~//[a-zA-Z0-9 ]+$~m' => '' , '/[\r\n]+([\t ]?[\r\n]+)+/s' => "\n" , '/\>[\r\n\t ]+\</s' => '><' , '/}[\r\n\t ]+/s' => '}' , '/}[\r\n\t ]+,[\r\n\t ]...
Minimise string removing all extra spaces new lines and any unneeded html content
47,660
public function occurrences ( string $ needle ) : array { $ offset = 0 ; $ allPositions = [ ] ; while ( ( $ position = strpos ( $ this -> string , $ needle , $ offset ) ) !== false ) { $ offset = $ position + 1 ; $ allPositions [ ] = $ position ; } return $ allPositions ; }
Find all the positions of occurrences of the given needle in the string
47,661
public function pad ( int $ length , string $ padding = ' ' ) : Utility { $ padLength = $ length - $ this -> length ( ) ; return $ this -> applyPadding ( floor ( $ padLength / 2 ) , ceil ( $ padLength / 2 ) , $ padding ) ; }
Pad the string with a value until it is the given length
47,662
public function padLeft ( $ length , $ padding = ' ' ) : Utility { return $ this -> applyPadding ( $ length - $ this -> length ( ) , 0 , $ padding ) ; }
Pad the left the string with a value until it is the given length
47,663
public function padRight ( $ length , $ padding = ' ' ) : Utility { return $ this -> applyPadding ( 0 , $ length - $ this -> length ( ) , $ padding ) ; }
Pad the right the string with a value until it is the given length
47,664
private function parameters ( $ parameters ) : array { $ values = ( ! is_array ( $ parameters ) ) ? [ $ parameters ] : $ parameters ; $ strings = [ ] ; foreach ( $ values as $ value ) { $ strings [ ] = self :: make ( $ value , $ this -> encoding ) ; } return $ strings ; }
Transform user input into a collection of Utility
47,665
private function prepareForCasing ( $ string ) : array { $ string = str_replace ( [ '.' , '_' , '-' ] , ' ' , $ string ) ; $ string = implode ( ' ' , preg_split ( '/(?<=\\w)(?=[A-Z])/' , $ string ) ) ; $ parts = preg_split ( '/(,?\s+)|((?<=[a-z])(?=\d))|((?<=\d)(?=[a-z]))/i' , $ string ) ; return array_values ( array_f...
Clean up and chunk a string ready for use in casing the string value
47,666
public function prepend ( $ prefix ) : Utility { return new static ( new static ( $ prefix , $ this -> encoding ) . $ this -> string , $ this -> encoding ) ; }
Prepend the string with a given value
47,667
public function removeRepeating ( string $ repeatingValue = ' ' ) : Utility { $ string = preg_replace ( '{(' . preg_quote ( $ repeatingValue ) . ')\1+}' , $ repeatingValue , $ this -> string ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove repeating characters from the value
47,668
public function removeSpace ( ) : Utility { $ string = preg_replace ( '~[[:cntrl:][:space:]]~' , '' , trim ( $ this -> string ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove all spaces and white space from the string
47,669
public function repeat ( int $ multiplier ) : Utility { $ string = str_repeat ( $ this -> string , $ multiplier ) ; return new static ( $ string , $ this -> encoding ) ; }
Repeat the string by the amount of the multiplier
47,670
public function replace ( $ find , $ with ) : Utility { $ replace = [ ] ; foreach ( $ this -> parameters ( $ find ) as $ parameter ) { $ replace [ ] = preg_quote ( $ parameter -> value ( ) ) ; } $ withString = new static ( $ with , $ this -> encoding ) ; $ string = preg_replace ( '#(' . implode ( '|' , $ replace ) . ')...
Replace occurrences in the string with a given value
47,671
public function replaceNonAlpha ( string $ replacement = '' , bool $ strict = false ) : Utility { if ( $ strict ) { $ pattern = '/[^a-zA-Z]/' ; } else { $ pattern = '/[^a-zA-Z ]/' ; } $ string = preg_replace ( $ pattern , $ replacement , trim ( $ this -> string ) ) ; return new static ( $ string , $ this -> encoding ) ...
Replace none alpha characters in the string with the given value
47,672
public function reverse ( ) : Utility { $ string = '' ; for ( $ i = $ this -> length ( ) - 1 ; $ i >= 0 ; $ i -- ) { $ string .= \ mb_substr ( $ this -> string , $ i , 1 , $ this -> encoding ) ; } return new static ( $ string , $ this -> encoding ) ; }
Reverse the string
47,673
public function surround ( $ with ) : Utility { $ surrounding = new static ( $ with , $ this -> encoding ) ; return new static ( implode ( '' , [ $ surrounding , $ this -> string , $ surrounding ] ) , $ this -> encoding ) ; }
Wrap the the string with a value
47,674
public function toCamelCase ( ) : Utility { $ string = preg_replace ( '/([a-z0-9])(?=[A-Z])/' , '$1 ' , $ this -> string ) ; $ words = preg_split ( '/[\W_]/' , $ string ) ; $ words = array_map ( function ( $ word ) { return ucfirst ( strtolower ( $ word ) ) ; } , $ words ) ; $ string = lcfirst ( implode ( '' , $ words ...
Transform the value to into camelCase format
47,675
public function toPascalCase ( ) : Utility { $ string = ucfirst ( $ this -> toCamelCase ( ) -> value ( ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to into PascalCase format
47,676
public function toSentence ( ) : Utility { $ sentences = preg_split ( '/([^\.\!\?;]+[\.\!\?;"]+)/' , $ this -> string , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ sentences = array_map ( function ( $ sentence ) { $ sentence = trim ( $ sentence ) ; if ( ! ctype_upper ( $ sentence [ 0 ] ) ) { $ sentence =...
Turn the string into a sentence .
47,677
public function toSlug ( string $ separator = '-' ) : Utility { $ string = mb_convert_encoding ( $ this -> string , 'UTF-8' , $ this -> encoding ) ; $ string = preg_replace ( '/[^\s\p{L}0-9\-' . $ separator . ']/u' , '' , $ string ) ; $ string = htmlentities ( $ string , ENT_QUOTES , 'UTF-8' ) ; $ string = preg_replace...
Clean a string to only have alpha numeric characters turn spaces into a separator slug
47,678
public function toSlugUtf8 ( string $ separator = '-' ) : Utility { $ string = mb_convert_encoding ( $ this -> string , 'UTF-8' , $ this -> encoding ) ; $ string = preg_replace ( '/[^\s\p{L}0-9\-' . $ separator . ']/u' , '' , $ string ) ; $ string = preg_replace ( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|s...
Same as toSlug but preserves UTF8 characters
47,679
public function toSnakeCase ( ) : Utility { $ string = mb_ereg_replace ( '\B([A-Z])' , '-\1' , trim ( $ this -> string ) ) ; $ string = mb_strtolower ( $ string , $ this -> encoding ) ; $ string = mb_ereg_replace ( '[-_\s]+' , '_' , $ string ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to snake_case format
47,680
public function toStudlyCase ( ) : Utility { $ string = implode ( ' ' , $ this -> prepareForCasing ( $ this -> string ) ) ; $ string = str_replace ( ' ' , '' , ucwords ( $ string ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to StudlyCase format
47,681
public function toTitleCase ( ) : Utility { $ words = explode ( ' ' , $ this -> string ) ; $ string = mb_convert_case ( implode ( ' ' , $ words ) , MB_CASE_TITLE , $ this -> encoding ( ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Transform the value to into Title Case format
47,682
public function trim ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = trim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using trim
47,683
public function trimLeft ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = ltrim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using rtrim
47,684
public function trimRight ( $ values = " \t\n\r\0\x0B" ) : Utility { $ parameters = $ this -> parameters ( $ values ) ; $ string = rtrim ( $ this -> string , implode ( '' , $ parameters ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Trim a collection of values from the string using ltrim
47,685
public function alterColumn ( $ name , $ attrib , $ value ) { $ this -> requireColumn ( $ name ) ; $ newColumns = $ this -> _columns ; if ( $ attrib === null ) { unset ( $ newColumns [ $ name ] ) ; } else { $ newColumn = $ newColumns [ $ name ] -> toArray ( ) ; $ newColumn [ $ attrib ] = $ value ; $ newColumns [ $ name...
Internal method to alter a column
47,686
protected function _renameToTmp ( ) { $ tmpTableName = $ this -> _name ; $ tableNames = $ this -> _database -> getTableNames ( ) ; do { $ tmpTableName .= '_bak' ; } while ( in_array ( $ tmpTableName , $ tableNames ) ) ; $ tmpTableName = $ this -> _database -> quoteIdentifier ( $ tmpTableName ) ; $ this -> alter ( "RENA...
Rename table to a unique temporary name
47,687
public function dump ( array $ options = array ( ) ) { if ( ! class_exists ( 'zxf\Symfony\Component\Yaml\Dumper' ) ) { throw new RuntimeException ( 'Unable to dump the container as the Symfony Yaml Component is not installed.' ) ; } if ( null === $ this -> dumper ) { $ this -> dumper = new YmlDumper ( ) ; } return $ th...
Dumps the service container as an YAML string .
47,688
private function addServices ( ) { if ( ! $ this -> container -> getDefinitions ( ) ) { return '' ; } $ code = "services:\n" ; foreach ( $ this -> container -> getDefinitions ( ) as $ id => $ definition ) { $ code .= $ this -> addService ( $ id , $ definition ) ; } $ aliases = $ this -> container -> getAliases ( ) ; fo...
Adds services .
47,689
private function prepareParameters ( array $ parameters , $ escape = true ) { $ filtered = array ( ) ; foreach ( $ parameters as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = $ this -> prepareParameters ( $ value , $ escape ) ; } elseif ( $ value instanceof Reference || is_string ( $ value ) && 0 === str...
Prepares parameters .
47,690
public function render ( $ view , array $ data = null ) { foreach ( get_object_vars ( $ this ) as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> unguarded ) ) { $ this -> $ key = $ this -> scrub ( $ value ) ; } } $ data = $ this -> scrub ( $ data ) ; return parent :: render ( $ view , $ data ) ; }
Return our compiled view . Sanitize the data before rendering .
47,691
public function output ( $ view , array $ data = null ) { $ response = new Response ( $ this -> render ( $ view , $ data ) , Response :: HTTP_OK , [ 'Content-Type' => 'text/html' ] ) ; $ response -> send ( ) ; }
Output the content instead of just render .
47,692
public function scrub ( $ var ) { if ( is_string ( $ var ) ) { return $ this -> escape ( $ var ) ; } elseif ( is_array ( $ var ) ) { foreach ( $ var as $ key => $ value ) { if ( ! in_array ( ( string ) $ key , $ this -> unguarded ) ) { $ var [ $ key ] = $ this -> scrub ( $ value ) ; } } return $ var ; } elseif ( is_obj...
Recursively sanitize output .
47,693
public function unguard ( $ key ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k ) { $ this -> unguard ( $ k ) ; } } else { $ this -> unguarded [ ] = $ key ; } }
Don t escape template variables with the specified name .
47,694
public final function contains ( Rectangle $ rect ) : bool { return ( ( ( ( $ this -> point -> x <= $ rect -> point -> x ) && ( ( $ rect -> point -> x + $ rect -> size -> width ) <= ( $ this -> point -> x + $ this -> size -> width ) ) ) && ( $ this -> point -> y <= $ rect -> point -> y ) ) && ( ( $ rect -> point -> y +...
Returns if the current rectangle contains the defined rectangle .
47,695
public final function containsLocation ( $ xOrPoint , int $ y = null ) : bool { $ x = $ xOrPoint ; if ( $ x instanceof Point ) { $ y = $ x -> y ; $ x = $ x -> x ; } else if ( \ is_integer ( $ xOrPoint ) ) { $ x = $ xOrPoint ; } else if ( TypeTool :: IsInteger ( $ xOrPoint ) ) { $ x = \ intval ( $ xOrPoint ) ; } else { ...
Returns if the current rectangle contains the defined location .
47,696
public final function containsSize ( $ widthOrSize , int $ height = null ) : bool { $ width = $ widthOrSize ; if ( $ width instanceof Size ) { $ height = $ width -> height ; $ width = $ width -> width ; } else if ( \ is_integer ( $ widthOrSize ) ) { $ width = $ widthOrSize ; } else if ( TypeTool :: IsInteger ( $ widthO...
Returns if the current rectangle contains the defined Size .
47,697
public function getClone ( ) : Rectangle { return new Rectangle ( new Point ( $ this -> point -> x , $ this -> point -> y ) , new Size ( $ this -> size -> width , $ this -> size -> height ) ) ; }
Gets a clone of the current instance .
47,698
public function toArray ( ) : array { return [ 'x' => $ this -> point -> x , 'y' => $ this -> point -> y , 'width' => $ this -> size -> width , 'height' => $ this -> size -> height ] ; }
Returns a array with all instance data . Used array keys are x y width and height .
47,699
public function generateProcessProxy ( $ arguments = array ( ) ) { if ( ! $ this -> isProxyLoaded ( ) ) { $ this -> loadProxyClass ( ) ; } $ reflect = new ReflectionClass ( $ this -> proxyClass ) ; return $ reflect -> newInstanceArgs ( $ arguments ) ; }
Instantiate and returns a step proxy .