idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
46,700
public function sendEmail ( $ dest , $ subject , $ html , $ text ) { $ mail = [ 'Destination' => $ this -> buildDestination ( $ dest ) , 'Message' => [ 'Body' => [ 'Html' => [ 'Charset' => $ this -> charset , 'Data' => $ html ] , 'Text' => [ 'Charset' => $ this -> charset , 'Data' => $ text ] , ] , 'Subject' => [ 'Charset' => $ this -> charset , 'Data' => $ subject ] , ] , 'Source' => $ this -> from , ] ; if ( $ this -> tags ) $ mail [ 'Tags' ] = $ this -> buildTags ( ) ; return $ this -> invokeMethod ( "sendEmail" , $ mail , true ) ; }
Send simple formatted email . No attachments .
46,701
public function sendRawEmail ( $ raw_data , $ dest = [ ] ) { if ( $ this -> isVersion2 ( ) && base64_decode ( $ raw_data , true ) === false ) $ raw_data = base64_encode ( $ raw_data ) ; $ mail = [ 'Source' => $ this -> from , 'RawMessage' => [ 'Data' => $ raw_data ] , ] ; if ( $ dest ) $ mail [ 'Destinations' ] = $ dest ; if ( $ this -> tags ) $ mail [ 'Tags' ] = $ this -> buildTags ( ) ; return $ this -> invokeMethod ( "sendRawEmail" , $ mail , true ) ; }
Send raw email . Beware of differences between Api v2 and v3
46,702
private function buildDestination ( $ emails ) { $ ret = [ 'ToAddresses' => isset ( $ emails [ 'to' ] ) ? $ emails [ 'to' ] : array_values ( $ emails ) ] ; if ( isset ( $ emails [ 'cc' ] ) && $ emails [ 'cc' ] ) $ ret [ 'CcAddresses' ] = $ emails [ 'cc' ] ; if ( isset ( $ emails [ 'bcc' ] ) && $ emails [ 'cc' ] ) $ ret [ 'BccAddresses' ] = $ emails [ 'bcc' ] ; return $ ret ; }
Create an array mapped with ToAddesses CcAddresses BccAddresses
46,703
private function buildDestinations ( $ destinations ) { $ ret = array ( ) ; foreach ( $ destinations as $ dest ) { $ d = [ "Destination" => $ this -> buildDestination ( $ dest [ "dest" ] ) , "ReplacementTemplateData" => $ this -> buildReplacements ( $ dest [ "data" ] ) ] ; if ( isset ( $ dest [ "tags" ] ) && $ dest [ "tags" ] ) $ d [ 'ReplacementTags' ] = $ this -> buildTags ( $ dest [ "tags" ] ) ; $ ret [ ] = $ d ; } return $ ret ; }
Create an array of destinations for bulk mail send
46,704
public function codeUnit ( ) { $ result = \ unpack ( 'N' , \ mb_convert_encoding ( $ this -> _Value , 'UCS-4BE' , 'UTF-8' ) ) ; if ( \ is_array ( $ result ) ) { return $ result [ 1 ] ; } return \ ord ( $ this -> _Value ) ; }
Returns the UTF - 8 code unit for the string . This is only useful on single - character strings
46,705
public function compareTo ( $ obj ) { if ( ! ( $ obj instanceof static ) ) { throw new \ InvalidArgumentException ( '$obj is not a comparable instance' ) ; } $ coll = new \ Collator ( '' ) ; return $ coll -> compare ( $ this -> _Value , $ obj -> _Value ) ; }
Compares this string against a given string lexicographically
46,706
public function convertEncoding ( $ newEncoding ) { if ( ! \ is_string ( $ newEncoding ) ) { throw new \ InvalidArgumentException ( '$newEncoding must be a string' ) ; } $ newEncoding = \ strtoupper ( $ newEncoding ) ; return new static ( \ mb_convert_encoding ( $ this -> _Value , $ newEncoding , $ this -> _Encoding ) , $ newEncoding ) ; }
Converts the string to a new encoding
46,707
public static function fromCodeUnit ( $ unit ) { if ( ! \ is_numeric ( $ unit ) ) { throw new \ InvalidArgumentException ( '$unit must be a number' ) ; } $ str = \ mb_convert_encoding ( \ sprintf ( '&#%s;' , $ unit ) , static :: ENCODING , 'HTML-ENTITIES' ) ; return new static ( $ str , static :: ENCODING ) ; }
Converts a code unit to a unicode character in UTF - 8 encoding
46,708
public static function fromString ( $ str , $ encoding = self :: ENCODING ) { if ( ! \ is_string ( $ str ) ) { throw new \ InvalidArgumentException ( '$str must be a PHP string' ) ; } if ( ! \ is_string ( $ encoding ) ) { throw new \ InvalidArgumentException ( '$encoding must be a string' ) ; } return new static ( $ str , $ encoding ) ; }
Create a String from a PHP string
46,709
public function indexOf ( self $ str , $ offset = 0 , MStringComparison $ cmp = null ) { if ( ! $ this -> offsetExists ( $ offset ) ) { throw new \ OutOfRangeException ( '$offset is invalid' ) ; } if ( $ cmp === null || $ cmp -> Value === MStringComparison :: CASE_SENSITIVE ) { $ index = \ mb_strpos ( $ this -> _Value , $ str -> _Value , $ offset , $ this -> _Encoding ) ; } else { $ index = \ mb_stripos ( $ this -> _Value , $ str -> _Value , $ offset , $ this -> _Encoding ) ; } return $ index !== false ? $ index : static :: NO_INDEX ; }
Returns the index of a given string in this string
46,710
public function insert ( $ index , self $ str ) { if ( ! $ this -> offsetExists ( $ index ) ) { throw new \ OutOfRangeException ( '$index is invalid' ) ; } return new static ( $ this -> substring ( 0 , $ index ) . $ str -> _Value . $ this -> substring ( $ index ) , $ this -> _Encoding ) ; }
Returns a new string with a given string inserted at a given index
46,711
public function lastIndexOf ( self $ str , $ offset = 0 , MStringComparison $ cmp = null ) { if ( ! $ this -> offsetExists ( $ offset ) ) { throw new \ OutOfRangeException ( '$offset is invalid' ) ; } if ( $ cmp === null || $ cmp -> Value === MStringComparison :: CASE_SENSITIVE ) { $ index = \ mb_strrpos ( $ this -> _Value , $ str -> _Value , $ offset , $ this -> _Encoding ) ; } else { $ index = \ mb_strripos ( $ this -> _Value , $ str -> _Value , $ offset , $ this -> _Encoding ) ; } return $ index !== false ? $ index : static :: NO_INDEX ; }
Returns the last index of a given string
46,712
public function lcfirst ( ) { if ( $ this -> isNullOrWhitespace ( ) ) { return clone $ this ; } else if ( $ this -> count ( ) === 1 ) { return new static ( \ mb_strtolower ( $ this -> _Value , $ this -> _Encoding ) , $ this -> _Encoding ) ; } $ str = $ this [ 0 ] -> lcfirst ( ) . $ this -> substring ( 1 ) ; return new static ( $ str , $ this -> _Encoding ) ; }
Returns a new string with the first character in lower case
46,713
public function slowEquals ( self $ str ) { $ l1 = \ strlen ( $ this -> _Value ) ; $ l2 = \ strlen ( $ str -> _Value ) ; $ diff = $ l1 ^ $ l2 ; for ( $ i = 0 ; $ i < $ l1 && $ i < $ l2 ; ++ $ i ) { $ diff |= \ ord ( $ this -> _Value [ $ i ] ) ^ \ ord ( $ str -> _Encoding [ $ i ] ) ; } return $ diff === 0 ; }
Checks for string equality in constant time
46,714
public function substring ( $ start , $ length = null ) { if ( ! $ this -> offsetExists ( $ start ) ) { throw new \ OutOfRangeException ( '$start is an invalid index' ) ; } if ( $ length !== null && ! \ is_numeric ( $ length ) || $ length < 0 ) { throw new \ InvalidArgumentException ( '$length is invalid' ) ; } return new static ( \ mb_substr ( $ this -> _Value , $ start , $ length , $ this -> _Encoding ) , $ this -> _Encoding ) ; }
Returns a new string as a substring from the current one
46,715
public function split ( $ regex = '//u' , $ limit = - 1 ) { if ( ! \ is_string ( $ regex ) ) { throw new \ InvalidArgumentException ( '$regex is not a string' ) ; } if ( ! \ is_numeric ( $ limit ) ) { throw new \ InvalidArgumentException ( '$limit is not a number' ) ; } return \ preg_split ( $ regex , $ this -> _Value , $ limit , \ PREG_SPLIT_NO_EMPTY ) ; }
Splits this string according to a regular expression
46,716
public function startsWith ( self $ str , MStringComparison $ cmp = null ) { if ( $ str -> isNullOrEmpty ( ) ) { throw new \ InvalidArgumentException ( '$str is empty' ) ; } if ( $ str -> count ( ) > $ this -> count ( ) ) { throw new \ InvalidArgumentException ( '$str is longer than $this' ) ; } if ( $ cmp === null || $ cmp -> getValue ( ) === MStringComparison :: CASE_SENSITIVE ) { return $ this -> substring ( 0 , $ str -> count ( ) ) -> _Value === $ str -> _Value ; } else { return $ this -> substring ( 0 , $ str -> count ( ) ) -> toLower ( ) -> _Value === $ str -> toLower ( ) -> _Value ; } }
Whether this string starts with a given string
46,717
public function toCharArray ( ) { $ arr = array ( ) ; for ( $ i = 0 , $ l = $ this -> count ( ) ; $ i < $ l ; ++ $ i ) { $ arr [ ] = \ mb_substr ( $ this -> _Value , $ i , 1 , $ this -> _Encoding ) ; } return $ arr ; }
Returns an array of each character in this string
46,718
public function trim ( array $ chars = null ) { if ( $ chars === null ) { return new static ( \ trim ( $ this -> _Value ) , $ this -> _Encoding ) ; } $ chars = \ preg_quote ( \ implode ( static :: NONE , $ chars ) ) ; $ str = \ preg_replace ( \ sprintf ( '/(^[%s]+)|([%s]+$)/us' , $ chars , $ chars ) , static :: NONE , $ this -> _Value ) ; return new static ( $ str , $ this -> _Encoding ) ; }
Trims whitespace or a set of characters from both ends of this string
46,719
public function trimEnd ( array $ chars = null ) { if ( $ chars === null ) { return new static ( \ rtrim ( $ this -> _Value ) , $ this -> _Encoding ) ; } $ chars = \ preg_quote ( \ implode ( static :: NONE , $ chars ) ) ; $ str = \ preg_replace ( \ sprintf ( '/[%s]+$/us' , $ chars ) , static :: NONE , $ this -> _Value ) ; return new static ( $ str , $ this -> _Encoding ) ; }
Trims whitespace or a set of characters from the end of this string
46,720
public function trimStart ( array $ chars = null ) { if ( $ chars === null ) { return new static ( \ ltrim ( $ this -> _Value ) , $ this -> _Encoding ) ; } $ chars = \ preg_quote ( \ implode ( static :: NONE , $ chars ) ) ; $ str = \ preg_replace ( \ sprintf ( '/^[%s]+/us' , $ chars ) , static :: NONE , $ this -> _Value ) ; return new static ( $ str , $ this -> _Encoding ) ; }
Trims whitespace or a set of characters from the beginning of this string
46,721
public function ucfirst ( ) { if ( $ this -> isNullOrWhitespace ( ) ) { return clone $ this ; } else if ( $ this -> count ( ) === 1 ) { return new static ( \ mb_strtoupper ( $ this -> _Value , $ this -> _Encoding ) , $ this -> _Encoding ) ; } $ str = $ this [ 0 ] -> ucfirst ( ) . $ this -> substring ( 1 ) ; return new static ( $ str , $ this -> _Encoding ) ; }
Returns a new string with the first character in upper case
46,722
public function unserialize ( $ serialized ) { $ arr = \ unserialize ( $ serialized ) ; $ this -> _Value = $ arr [ 0 ] ; $ this -> _Encoding = $ arr [ 1 ] ; }
Unserializes a serialized string
46,723
public function download ( $ pathToFile , $ name = null , array $ headers = array ( ) ) { $ response = StaticClient :: get ( $ this -> offsetGet ( '_downloadURL' ) , array ( 'headers' => $ headers , 'timeout' => $ this -> timeout , 'save_to' => $ pathToFile , ) ) ; file_put_contents ( $ pathToFile , $ response -> getBody ( ) -> getStream ( ) ) ; }
Download the file to a local path .
46,724
public function withType ( $ value ) { $ new = clone $ this ; $ new -> headers [ Header \ ContentType :: name ( ) ] = [ ] ; $ new -> headers [ Header \ ContentType :: name ( ) ] [ ] = $ value ; return $ new ; }
Return an instance with the provided value replacing the Content - Type header .
46,725
public function withLanguage ( $ value ) { $ new = clone $ this ; $ new -> headers [ Header \ Language :: name ( ) ] = [ ] ; $ new -> headers [ Header \ Language :: name ( ) ] [ ] = $ value ; return $ new ; }
Return an instance with the provided value replacing the Language header .
46,726
public function withTypeNegotiation ( $ strongNegotiation = false ) { $ negotiation = array_intersect ( Request \ AcceptType :: getContent ( ) , Support \ TypeSupport :: getSupport ( ) ) ; $ content = '' ; if ( count ( $ negotiation ) > 0 ) { $ content = current ( $ negotiation ) ; } else { if ( $ strongNegotiation ) { $ this -> failTypeNegotiation ( ) ; } else { $ content = Support \ TypeSupport :: getSupport ( ) ; $ content = $ content [ 0 ] ; } } return $ this -> withType ( $ content ) ; }
Negotiate Mime types
46,727
public function withAddedType ( $ value ) { $ new = clone $ this ; if ( empty ( $ new -> headers [ Header \ ContentType :: name ( ) ] ) ) { $ new -> headers [ Header \ ContentType :: name ( ) ] = [ ] ; } $ new -> headers [ Header \ ContentType :: name ( ) ] [ ] = $ value ; return $ new ; }
Return an instance with the Content - Type header appended with the given value .
46,728
public function withAddedLanguage ( $ value ) { $ new = clone $ this ; if ( empty ( $ new -> headers [ Header \ Language :: name ( ) ] ) ) { $ new -> headers [ Header \ Language :: name ( ) ] = [ ] ; } $ new -> headers [ Header \ Language :: name ( ) ] [ ] = $ value ; return $ new ; }
Return an instance with the Language header appended with the given value .
46,729
protected function failTypeNegotiation ( ) { $ supported = Request \ TypeSupport :: getSupport ( ) ; $ clientSupport = Request \ AcceptType :: getContent ( ) ; $ supported = implode ( ',' , $ supported ) ; $ clientSupport = implode ( ',' , $ clientSupport ) ; $ this -> withStatus ( 406 ) -> withType ( Response \ ContentType :: TEXT ) -> write ( "NOT SUPPORTED\nThis server does not support {$supported}.\nSupported formats: {$clientSupport}" ) -> send ( ) ; exit ( 1 ) ; }
Send a 406 response for failed content negotiation
46,730
public function overwrite ( $ data ) { $ body = $ this -> getBody ( ) ; $ body -> rewind ( ) ; $ body -> write ( $ data ) ; return $ this ; }
Write content to the stream by overwriting existing content
46,731
public function send ( ) { header ( $ this -> getStatusStr ( ) ) ; foreach ( $ this -> headers as $ header => $ value ) { header ( sprintf ( "%s: %s" , $ header , implode ( ',' , $ value ) ) ) ; } $ body = $ this -> getBody ( ) ; if ( $ body -> isAttached ( ) ) { $ body -> rewind ( ) ; while ( ! $ body -> eof ( ) ) { echo $ body -> read ( $ this -> bodySize ) ; } } }
Send the Response object over the wire
46,732
public function dropDatabase ( ) : void { $ tables = $ this -> getTables ( ) ; if ( ! empty ( $ tables ) ) { $ this -> connection -> query ( 'SET foreign_key_checks = 0' ) ; foreach ( $ tables as $ table ) { $ this -> connection -> query ( 'DROP TABLE %table' , $ table ) ; } $ this -> connection -> query ( 'SET foreign_key_checks = 1' ) ; } }
Smaze vsechny tabulky v databazi
46,733
public function camelizeBundle ( $ string ) { $ string = $ this -> camelize ( $ string ) ; $ string = str_replace ( '_bundle' , '' , $ string ) ; return $ string ; }
camelize a bundle name .
46,734
public function indexAction ( Request $ request ) { $ query = $ request -> query -> get ( 'query' ) ; $ limit = $ request -> query -> get ( 'limit' ) ; $ start = $ request -> query -> get ( 'start' ) ; $ searchProviders = $ this -> get ( 'search.providers' ) ; $ content = '' ; $ content .= '<h3>Registered Search Providers:</h3><table><tr><th>Class</th><th>Resource</th><th>Search key</th></tr>' ; foreach ( $ searchProviders as $ searchProvider ) { $ content .= '<tr>' ; $ content .= '<td>' . get_class ( $ searchProvider ) . '</td>' ; $ content .= '<td>' . $ searchProvider -> getResource ( ) . '</td>' ; $ content .= '<td>' . $ searchProvider -> getSearchKey ( ) . '</td>' ; $ content .= '</tr>' ; } $ content .= '</table>' ; $ content .= '<h3>Search:</h3>' ; $ content .= '<form><input name="query" value="' . $ query . '"/><input type="submit" value="send" /></form>' ; if ( $ query ) { $ content .= '<h3>Results:</h3>' ; $ search = $ this -> getContainer ( ) -> get ( 'search.search' ) ; $ results = $ search -> search ( $ query ) ; $ content .= '<pre>' ; $ content .= print_r ( $ results , true ) ; $ content .= '</pre>' ; } return new Response ( $ content ) ; }
Return Search results .
46,735
public function loadSiteScripts ( ) { if ( is_singular ( ) && comments_open ( ) && get_option ( 'thread_comments' ) ) { wp_enqueue_script ( 'comment-reply' ) ; } $ mainHandle = 'site' ; $ this -> loadMainScriptByHandle ( $ mainHandle ) ; $ viewHandle = $ this -> getViewHandle ( ) ; if ( file_exists ( sprintf ( '%s/js/views/%s.js' , $ this -> paths -> getThemeAssetsDir ( ) , $ viewHandle ) ) ) { $ viewSrc = sprintf ( '%s/js/views/%s.js' , $ this -> paths -> getThemeAssetsUri ( ) , $ viewHandle ) ; $ this -> loadScript ( $ viewHandle , $ viewSrc , [ $ mainHandle ] , true ) ; } }
Loads frontend scripts
46,736
public function loadSiteStyles ( ) { $ this -> loadCdnStyles ( ) ; $ mainHandle = 'site' ; $ this -> loadMainStyleByHandle ( $ mainHandle ) ; $ viewHandle = $ this -> getViewHandle ( ) ; if ( file_exists ( sprintf ( '%s/css/views/%s.css' , $ this -> paths -> getThemeAssetsDir ( ) , $ viewHandle ) ) ) { $ viewSrc = sprintf ( '%s/css/views/%s.css' , $ this -> paths -> getThemeAssetsUri ( ) , $ viewHandle ) ; $ this -> loadStyle ( $ viewHandle , $ viewSrc , [ $ mainHandle ] ) ; } }
Loads frontend styles
46,737
public function loadCustomizeScript ( ) { $ handle = 'novusopress_customize' ; $ url = sprintf ( '%s/js/customize.js' , $ this -> paths -> getBaseAssetsUri ( ) ) ; $ deps = [ 'jquery' , 'customize-preview' ] ; $ this -> loadScript ( $ handle , $ url , $ deps , true ) ; }
Loads customize page script
46,738
protected function loadCdnStyles ( ) { if ( file_exists ( sprintf ( '%s/cdn-styles.json' , $ this -> paths -> getThemeConfigDir ( ) ) ) ) { $ cdnContent = file_get_contents ( sprintf ( '%s/cdn-styles.json' , $ this -> paths -> getThemeConfigDir ( ) ) ) ; $ cdnStyles = json_decode ( $ cdnContent , true ) ; for ( $ i = 0 ; $ i < count ( $ cdnStyles ) ; $ i ++ ) { $ handle = $ i ? 'cdn' . $ i : 'cdn' ; wp_enqueue_style ( $ handle , $ cdnStyles [ $ i ] , [ ] , null ) ; } } }
Loads stylesheets from CDNs such as Google fonts
46,739
protected function loadMainScriptByHandle ( $ mainHandle ) { $ deps = $ this -> getScriptDeps ( $ mainHandle ) ; if ( file_exists ( sprintf ( '%s/js/%s.js' , $ this -> paths -> getThemeAssetsDir ( ) , $ mainHandle ) ) ) { $ mainSrc = sprintf ( '%s/js/%s.js' , $ this -> paths -> getThemeAssetsUri ( ) , $ mainHandle ) ; } else { $ mainSrc = sprintf ( '%s/js/%s.js' , $ this -> paths -> getBaseAssetsUri ( ) , $ mainHandle ) ; } $ this -> loadScript ( $ mainHandle , $ mainSrc , $ deps , true ) ; }
Loads a main script file using handle conventions
46,740
protected function loadMainStyleByHandle ( $ mainHandle ) { $ deps = $ this -> getStyleDeps ( $ mainHandle ) ; if ( file_exists ( sprintf ( '%s/css/%s.css' , $ this -> paths -> getThemeAssetsDir ( ) , $ mainHandle ) ) ) { $ mainSrc = sprintf ( '%s/css/%s.css' , $ this -> paths -> getThemeAssetsUri ( ) , $ mainHandle ) ; } else { $ mainSrc = sprintf ( '%s/css/%s.css' , $ this -> paths -> getBaseAssetsUri ( ) , $ mainHandle ) ; } $ this -> loadStyle ( $ mainHandle , $ mainSrc , $ deps ) ; }
Loads a main stylesheet file using handle conventions
46,741
protected function getScriptDeps ( $ section ) { $ dependencies = $ this -> getDependencies ( ) ; $ deps = isset ( $ dependencies [ 'scripts' ] ) ? $ dependencies [ 'scripts' ] : [ ] ; return isset ( $ deps [ $ section ] ) ? $ deps [ $ section ] : [ ] ; }
Retrieves script dependencies
46,742
protected function getStyleDeps ( $ section ) { $ dependencies = $ this -> getDependencies ( ) ; $ deps = isset ( $ dependencies [ 'styles' ] ) ? $ dependencies [ 'styles' ] : [ ] ; return isset ( $ deps [ $ section ] ) ? $ deps [ $ section ] : [ ] ; }
Retrieves style dependencies
46,743
protected function getDependencies ( ) { if ( null === $ this -> dependencies ) { if ( file_exists ( sprintf ( '%s/dependencies.json' , $ this -> paths -> getThemeConfigDir ( ) ) ) ) { $ depsContent = file_get_contents ( sprintf ( '%s/dependencies.json' , $ this -> paths -> getThemeConfigDir ( ) ) ) ; } else { $ depsContent = file_get_contents ( sprintf ( '%s/dependencies.json' , $ this -> paths -> getBaseConfigDir ( ) ) ) ; } $ this -> dependencies = json_decode ( $ depsContent , true ) ; } return $ this -> dependencies ; }
Retrieves the dependencies config
46,744
protected function getViewHandle ( ) { if ( is_front_page ( ) && is_home ( ) ) { return 'index' ; } elseif ( is_front_page ( ) ) { return 'front-page' ; } elseif ( is_home ( ) ) { return 'index' ; } elseif ( is_page_template ( ) ) { global $ wp_query ; $ templateName = get_post_meta ( $ wp_query -> post -> ID , '_wp_page_template' , true ) ; return substr ( $ templateName , 0 , - 4 ) ; } elseif ( is_page ( ) ) { return 'page' ; } elseif ( is_attachment ( ) ) { return 'attacment' ; } elseif ( is_single ( ) ) { return 'single' ; } elseif ( is_archive ( ) ) { return 'archive' ; } elseif ( is_search ( ) ) { return 'search' ; } return 'not-found' ; }
Retrieves the current view handle
46,745
public static function group ( array $ properties , array $ routes ) { if ( isset ( $ properties [ 'filter' ] ) ) { if ( ! is_array ( $ properties [ 'filter' ] ) ) { $ properties [ 'filter' ] = [ $ properties [ 'filter' ] ] ; } } else { $ properties [ 'filter' ] = [ ] ; } $ baseProperties = [ 'prefix' => '' , 'rprefix' => '' ] ; $ properties = array_merge ( $ baseProperties , $ properties ) ; foreach ( $ routes as $ route ) { $ httpmethod = $ route [ 0 ] ; if ( ! method_exists ( __CLASS__ , $ httpmethod ) ) { continue ; } $ pattern = $ properties [ 'prefix' ] . $ route [ 1 ] ; $ callback = $ properties [ 'rprefix' ] . $ route [ 2 ] ; $ options = [ 'filter' => $ properties [ 'filter' ] ] ; self :: $ httpmethod ( $ pattern , $ callback , $ options ) ; } }
Register a group of routes
46,746
public static function route ( Http \ Request $ request ) { $ path = $ request -> REQUEST_URI ; $ key = $ request -> getMethod ( ) . '@' . $ path ; $ keyAny = 'ANY@' . $ path ; $ matchedRoute = null ; $ matchedScore = 0 ; if ( isset ( self :: $ routes [ $ key ] ) ) { $ matchedRoute = self :: $ routes [ $ key ] ; } elseif ( isset ( self :: $ routes [ $ keyAny ] ) ) { $ matchedRoute = self :: $ routes [ $ keyAny ] ; } else { foreach ( self :: $ routes as $ key2 => $ route ) { if ( $ route -> getMethod ( ) != 'ANY' && $ route -> getMethod ( ) != $ request -> getMethod ( ) ) { continue ; } $ score = $ route -> getScore ( $ path , $ request -> getMethod ( ) ) ; if ( $ score > $ matchedScore ) { $ matchedRoute = $ route ; $ matchedScore = $ score ; } } } if ( $ matchedRoute ) { $ matchedRoute -> setUrl ( $ path ) ; } elseif ( self :: $ _404route ) { $ matchedRoute = self :: $ _404route ; } else { throw new Exceptions \ RouteException ( 'Route not found' ) ; } return $ matchedRoute ; }
Initiate the routing for the given URL
46,747
public function fullBoot ( $ package , $ dir ) { $ this -> mapRoutes ( $ dir ) ; if ( file_exists ( $ dir . '/views' ) ) { $ this -> loadViewsFrom ( $ dir . '/views' , $ package ) ; } if ( file_exists ( $ dir . '/migrations' ) ) { $ this -> publishes ( [ $ dir . '/migrations' => base_path ( 'database/migrations/' ) ] , 'migrations' ) ; } if ( file_exists ( $ dir . '/seeds' ) ) { $ this -> publishes ( [ $ dir . '/seeds' => base_path ( 'database/seeds/' ) ] , 'seeds' ) ; } if ( file_exists ( $ dir . "config/$package.php" ) ) { $ this -> mergeConfigFrom ( $ dir . "config/$package.php" , $ package ) ; $ this -> publishes ( [ $ dir . '/config' => base_path ( 'config' ) ] , 'config' ) ; } if ( file_exists ( $ dir . '/lang' ) ) { $ this -> publishes ( [ $ dir . '/lang' => resource_path ( ) . "/lang/vendor/$package" , ] ) ; $ this -> loadTranslationsFrom ( $ dir . "/lang" , $ package ) ; } if ( file_exists ( $ dir . '/assets' ) ) { $ this -> publishes ( [ $ dir . '/assets' => base_path ( 'resources/assets' ) , ] , 'assets' ) ; } if ( file_exists ( $ dir . '/factories/ModelFactory.php' ) ) { require ( $ dir . '/factories/ModelFactory.php' ) ; } }
it replace most thing that you can in boot in provider for packages
46,748
private function reindex ( int $ capacity ) : void { $ temp = [ ] ; for ( $ i = 0 ; $ i < $ this -> count ; $ i ++ ) { $ temp [ $ i ] = $ this -> items [ ( $ i + $ this -> front ) % $ this -> cap ] ; } $ this -> items = $ temp ; $ this -> cap = $ capacity ; $ this -> front = 0 ; $ this -> end = $ this -> count ; }
Re - indexes the underlying array
46,749
public function jpegToWbmp ( String $ jpegFile , String $ wbmpFile , Array $ settings = [ ] ) : Bool { if ( is_file ( $ jpegFile ) ) { $ height = $ settings [ 'height' ] ?? $ this -> height ?? 0 ; $ width = $ settings [ 'width' ] ?? $ this -> width ?? 0 ; $ threshold = $ settings [ 'threshold' ] ?? $ this -> threshold ?? 0 ; $ this -> defaultRevolvingVariables ( ) ; return jpeg2wbmp ( $ jpegFile , $ wbmpFile , $ height , $ width , $ threshold ) ; } else { return false ; } }
JPEG to WBMP
46,750
public function pngToWbmp ( String $ pngFile , String $ wbmpFile , Array $ settings = [ ] ) : Bool { if ( is_file ( $ pngFile ) ) { $ height = $ settings [ 'height' ] ?? 0 ; $ width = $ settings [ 'width' ] ?? 0 ; $ threshold = $ settings [ 'threshold' ] ?? 0 ; return png2wbmp ( $ pngFile , $ wbmpFile , $ height , $ width , $ threshold ) ; } else { return false ; } }
PNG to WBMP
46,751
public function alphaBlending ( Bool $ blendMode = NULL ) : GD { imagealphablending ( $ this -> canvas , ( bool ) $ blendMode ) ; return $ this ; }
Sets alpha blending
46,752
public function saveAlpha ( Bool $ save = true ) : GD { imagesavealpha ( $ this -> canvas , $ save ) ; return $ this ; }
Sets save alpha
46,753
public function pixelIndex ( Int $ x , Int $ y ) : Int { return imagecolorat ( $ this -> canvas , $ x , $ y ) ; }
Set pixel index
46,754
public function line ( Array $ settings = [ ] ) : GD { $ x1 = $ settings [ 'x1' ] ?? $ this -> x1 ?? 0 ; $ y1 = $ settings [ 'y1' ] ?? $ this -> y1 ?? 0 ; $ x2 = $ settings [ 'x2' ] ?? $ this -> x2 ?? 0 ; $ y2 = $ settings [ 'y2' ] ?? $ this -> y2 ?? 0 ; $ rgb = $ settings [ 'color' ] ?? $ this -> color ?? '0|0|0' ; $ type = $ settings [ 'type' ] ?? $ this -> type ?? 'solid' ; if ( $ type === 'solid' ) { imageline ( $ this -> canvas , $ x1 , $ y1 , $ x2 , $ y2 , $ this -> allocate ( $ rgb ) ) ; } elseif ( $ type === 'dashed' ) { imagedashedline ( $ this -> canvas , $ x1 , $ y1 , $ x2 , $ y2 , $ this -> allocate ( $ rgb ) ) ; } $ this -> defaultRevolvingVariables ( ) ; return $ this ; }
Creates a line
46,755
public function windowDisplay ( Int $ window , Int $ clientArea = 0 ) : GD { $ this -> canvas = imagegrabwindow ( $ window , $ clientArea ) ; return $ this ; }
Set window display
46,756
public function layerEffect ( String $ effect = 'normal' ) : GD { imagelayereffect ( $ this -> canvas , Helper :: toConstant ( $ effect , 'IMG_EFFECT_' ) ) ; return $ this ; }
Set layer effect
46,757
public function loadFont ( String $ file ) : Int { if ( ! is_file ( $ file ) ) { throw new InvalidArgumentException ( NULL , '[file]' ) ; } return imageloadfont ( $ file ) ; }
Set load font
46,758
public function copyPalette ( $ source ) { if ( ! is_resource ( $ source ) ) { throw new InvalidArgumentException ( NULL , '[resource]' ) ; } imagepalettecopy ( $ this -> canvas , $ source ) ; }
Get copy palette
46,759
protected function createImageCanvas ( $ image ) { $ this -> type = $ this -> mime -> type ( $ image , 1 ) ; $ this -> imageSize = ! isset ( $ this -> width ) ? getimagesize ( $ image ) : [ $ this -> width ?? 0 , $ this -> height ?? 0 ] ; $ this -> canvas = $ this -> createFrom ( $ image , [ 'x' => $ this -> x ?? 0 , 'y' => $ this -> y ?? 0 , 'width' => $ this -> width ?? $ this -> imageSize [ 0 ] , 'height' => $ this -> height ?? $ this -> imageSize [ 1 ] ] ) ; }
Protected create image canvas
46,760
protected function createEmptyCanvas ( $ width , $ height , $ rgb , $ real ) { $ width = $ this -> width ?? $ width ; $ height = $ this -> height ?? $ height ; $ rgb = $ this -> color ?? $ rgb ; $ real = $ this -> real ?? $ real ; $ this -> imageSize = [ $ width , $ height ] ; if ( $ real === false ) { $ this -> canvas = imagecreate ( $ width , $ height ) ; } else { $ this -> canvas = imagecreatetruecolor ( $ width , $ height ) ; } if ( ! empty ( $ rgb ) ) { $ this -> allocate ( $ rgb ) ; } }
Protected create empty canvas
46,761
protected function alignImageWatermark ( $ source ) { if ( is_string ( $ this -> target ?? NULL ) ) { $ size = getimagesize ( $ source ) ; $ this -> width = $ this -> width ?? $ size [ 0 ] ; $ this -> height = $ this -> height ?? $ size [ 1 ] ; $ return = WatermarkImageAligner :: align ( $ this -> target , $ this -> width , $ this -> height , $ this -> imageSize [ 0 ] , $ this -> imageSize [ 1 ] , $ this -> margin ?? 0 ) ; $ this -> target = $ return ; if ( isset ( $ this -> x ) ) $ this -> source [ 0 ] = $ this -> x ; if ( isset ( $ this -> y ) ) $ this -> source [ 1 ] = $ this -> y ; } }
Protected align image watermark
46,762
public function getImageColor ( $ rgb , $ function ) { $ rgb = explode ( '|' , $ rgb ) ; $ red = $ rgb [ 0 ] ?? 0 ; $ green = $ rgb [ 1 ] ?? 0 ; $ blue = $ rgb [ 2 ] ?? 0 ; $ alpha = $ rgb [ 3 ] ?? 0 ; return $ function ( $ this -> canvas , $ red , $ green , $ blue , $ alpha ) ; }
Protected Image Color
46,763
protected function defaultVariables ( ) { $ this -> canvas = NULL ; $ this -> save = NULL ; $ this -> output = true ; $ this -> quality = NULL ; }
Protected Default Variables
46,764
public function select ( $ fields = '*' ) { $ query = new Query \ SelectQuery ( ) ; if ( $ this -> pdo ) { $ query -> setPDO ( $ this -> pdo ) ; } return $ query -> select ( $ fields ) ; }
Creates a SELECT query .
46,765
public function insert ( array $ values ) { $ query = new Query \ InsertQuery ( ) ; if ( $ this -> pdo ) { $ query -> setPDO ( $ this -> pdo ) ; } return $ query -> values ( $ values ) ; }
Creates an INSERT query .
46,766
public function update ( $ table ) { $ query = new Query \ UpdateQuery ( ) ; if ( $ this -> pdo ) { $ query -> setPDO ( $ this -> pdo ) ; } return $ query -> table ( $ table ) ; }
Creates an UPDATE query .
46,767
public function delete ( $ from ) { $ query = new Query \ DeleteQuery ( ) ; if ( $ this -> pdo ) { $ query -> setPDO ( $ this -> pdo ) ; } return $ query -> from ( $ from ) ; }
Creates a DELETE query .
46,768
public function raw ( $ sql ) { $ query = new Query \ SqlQuery ( ) ; if ( $ this -> pdo ) { $ query -> setPDO ( $ this -> pdo ) ; } return $ query -> raw ( $ sql ) ; }
Creates a raw SQL query .
46,769
public function select ( $ columns = null ) { $ columns = func_get_args ( ) ; $ this -> _select = array_merge ( $ this -> _select , $ columns ) ; return $ this ; }
Choose the columns to select from .
46,770
public function select_array ( array $ columns , $ reset = false ) { $ this -> _select = $ reset ? $ columns : array_merge ( $ this -> _select , $ columns ) ; return $ this ; }
Choose the columns to select from using an array .
46,771
public function from ( $ tables ) { $ tables = func_get_args ( ) ; $ this -> _from = array_merge ( $ this -> _from , $ tables ) ; return $ this ; }
Choose the tables to select FROM ...
46,772
public function and_on ( $ c1 , $ op , $ c2 ) { $ this -> _last_join -> and_on ( $ c1 , $ op , $ c2 ) ; return $ this ; }
Adds AND ON ... conditions for the last created JOIN statement .
46,773
public function or_on ( $ c1 , $ op , $ c2 ) { $ this -> _last_join -> or_on ( $ c1 , $ op , $ c2 ) ; return $ this ; }
Adds OR ON ... conditions for the last created JOIN statement .
46,774
public static function compare ( Version $ a , Version $ b ) { $ aValues = $ a -> numeric ( ) ; $ bValues = $ b -> numeric ( ) ; foreach ( array_keys ( self :: $ ordinality ) as $ key ) { $ aVal = $ aValues [ $ key ] ; $ bVal = $ bValues [ $ key ] ; if ( $ aVal < $ bVal ) { return - 1 ; } elseif ( $ aVal > $ bVal ) { return 1 ; } } return 0 ; }
Comparator for version objects
46,775
public function increment ( $ part ) { foreach ( array_reverse ( self :: $ ordinality ) as $ currentPart ) { if ( $ currentPart === $ part ) { switch ( $ part ) { case self :: STABILITY : $ this -> set ( $ currentPart , self :: $ stabilities [ array_search ( $ this -> get ( $ currentPart ) , self :: $ stabilities ) + 1 ] ) ; break ; default : $ this -> set ( $ currentPart , $ this -> get ( $ currentPart ) + 1 ) ; break ; } break ; } else { switch ( $ currentPart ) { case self :: STABILITY_NO : $ this -> set ( $ currentPart , null ) ; break ; case self :: STABILITY : $ this -> set ( $ currentPart , 'dev' ) ; break ; default : $ this -> set ( $ currentPart , '0' ) ; } } } return $ this ; }
Increment a specific part of the version .
46,776
private function set ( $ part , $ value ) { if ( null === $ value && isset ( self :: $ defaults [ $ part ] ) ) { $ value = self :: $ defaults [ $ part ] ; } $ this -> parts [ $ part ] = $ value ; return $ this ; }
Set a specific part of the Version
46,777
public function format ( ) { $ ret = '' ; foreach ( self :: $ formats as $ key => $ format ) { $ value = $ this -> get ( $ key ) ; if ( $ key == self :: STABILITY && $ value == end ( self :: $ stabilities ) ) { break ; } $ ret .= sprintf ( $ format , $ value ) ; if ( $ key == self :: STABILITY && $ value == self :: $ stabilities [ 0 ] ) { break ; } } return $ ret ; }
Formats the version .
46,778
public function numeric ( ) { $ ret = array ( ) ; foreach ( self :: $ ordinality as $ part ) { if ( $ part === self :: STABILITY ) { $ ret [ ] = array_search ( $ this -> get ( $ part ) , self :: $ stabilities ) ; } else { $ ret [ ] = $ this -> get ( $ part ) ; } } return $ ret ; }
Returns a numeric representation of all version parts used for comparison
46,779
public function setBody ( $ responseBody ) { if ( $ this -> initialized !== true ) throw new \ Exception ( 'ResponseBuilder not initialized. Call init() first' ) ; if ( gettype ( $ responseBody ) != 'string' ) $ responseBody = $ responseBody -> getJSONString ( ) ; $ this -> sonicResponse -> setBody ( $ responseBody ) ; return $ this ; }
Sets the payload for the response . This needs to be an object that inherits from BasicObject
46,780
public static function checkFilter ( $ comment_string ) { $ pattern = "#(@[a-zA-Z]+\s*[a-zA-Z0-9, ()_].*)#" ; preg_match_all ( $ pattern , $ comment_string , $ matches , PREG_PATTERN_ORDER ) ; $ meta_data_array = $ matches [ 0 ] ; if ( count ( $ meta_data_array ) > 0 ) { $ beforeFilters = array ( ) ; $ afterFilters = array ( ) ; foreach ( $ meta_data_array as $ key => $ value ) { if ( strpos ( $ value , "@before" ) !== false ) { $ strb = explode ( ' ' , trim ( $ value ) ) ; $ strb = self :: clean ( $ strb ) ; ( isset ( $ strb [ 1 ] ) ) ? $ beforeFilters [ ] = $ strb [ 1 ] : '' ; ( isset ( $ strb [ 2 ] ) ) ? $ beforeFilters [ ] = $ strb [ 2 ] : '' ; } if ( strpos ( $ value , "@after" ) !== false ) { $ stra = explode ( ' ' , trim ( $ value ) ) ; $ stra = self :: clean ( $ stra ) ; ( isset ( $ stra [ 1 ] ) ) ? $ afterFilters [ ] = $ stra [ 1 ] : '' ; ( isset ( $ stra [ 2 ] ) ) ? $ afterFilters [ ] = $ stra [ 2 ] : '' ; } } $ return = array ( ) ; if ( ! empty ( $ beforeFilters ) ) $ return [ 'before' ] = $ beforeFilters ; if ( ! empty ( $ afterFilters ) ) $ return [ 'after' ] = $ afterFilters ; return $ return ; } else return false ; }
This method checks if a filter has been defined in the doc block .
46,781
public function get ( $ key ) { if ( ! isset ( $ this -> records [ $ key ] ) ) { return null ; } $ record = $ this -> records [ $ key ] ; if ( $ record [ 'expire' ] < time ( ) ) { unset ( $ this -> records [ $ key ] ) ; return null ; } return $ record [ 'nodes' ] ; }
Retrieve the nodes under the given key .
46,782
public function expires ( $ key ) { if ( ! isset ( $ this -> records [ $ key ] ) ) { return 0 ; } return ( int ) max ( 0 , $ this -> records [ $ key ] [ 'expire' ] - time ( ) ) ; }
Return seconds left until the key expires .
46,783
public function init ( ) { $ container = $ this -> getSessionContainer ( ) ; if ( isset ( $ container -> messages ) ) { $ this -> messages = $ container -> messages ; unset ( $ container -> messages ) ; } if ( isset ( $ container -> data ) ) { $ this -> data = $ container -> data ; unset ( $ container -> data ) ; } }
Initialize the messenger with the previous session messages
46,784
public function addMessage ( string $ type , $ message , string $ channel = FlashMessengerInterface :: DEFAULT_CHANNEL ) { if ( ! is_string ( $ message ) && ! is_array ( $ message ) ) { throw new InvalidArgumentException ( 'Flash message must be a string or an array of strings' ) ; } $ container = $ this -> getSessionContainer ( ) ; if ( ! isset ( $ container -> messages ) ) { $ container -> messages = [ ] ; } if ( ! isset ( $ container -> messages [ $ channel ] ) ) { $ container -> messages [ $ channel ] = [ ] ; } if ( ! isset ( $ container -> messages [ $ channel ] [ $ type ] ) ) { $ container -> messages [ $ channel ] [ $ type ] = [ ] ; } $ message = ( array ) $ message ; foreach ( $ message as $ msg ) { if ( ! is_string ( $ msg ) ) { throw new InvalidArgumentException ( 'Flash message must be a string or an array of strings' ) ; } $ container -> messages [ $ channel ] [ $ type ] [ ] = $ msg ; } }
Add flash message
46,785
public function report ( ) : ReportingResult { $ sets = [ ] ; $ errors = [ ] ; foreach ( $ this -> collectors as $ collector ) { $ sets [ ] = $ set = $ collector -> flush ( ) ; $ errors [ ] = $ this -> reportOn ( $ set ) ; } return new ReportingResult ( $ sets , array_merge ( ... $ errors ) ) ; }
Flush each collector and send its MetricSet to all the given reporters .
46,786
private function reportOn ( MetricSet $ set ) : array { $ errors = [ ] ; foreach ( $ this -> reporters as $ reporter ) { try { $ reporter -> reportOn ( $ set ) ; } catch ( \ Exception $ e ) { $ errors [ ] = $ e ; } } return $ errors ; }
Deliberately only catches Exception objects rather than all throwables .
46,787
public function registerAutoloadMap ( $ map ) { if ( is_string ( $ map ) ) { $ location = $ map ; if ( $ this === ( $ map = $ this -> loadMapFromFile ( $ location ) ) ) { return $ this ; } } if ( ! is_array ( $ map ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( 'Map file provided does not return a map' ) ; } $ this -> map = array_merge ( $ this -> map , $ map ) ; if ( isset ( $ location ) ) { $ this -> mapsLoaded [ ] = $ location ; } return $ this ; }
Register an autoload map
46,788
public function registerAutoloadMaps ( $ locations ) { if ( ! is_array ( $ locations ) && ! ( $ locations instanceof Traversable ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( 'Map list must be an array or implement Traversable' ) ; } foreach ( $ locations as $ location ) { $ this -> registerAutoloadMap ( $ location ) ; } return $ this ; }
Register many autoload maps at once
46,789
public function register ( ) { if ( version_compare ( PHP_VERSION , '5.3.0' , '>=' ) ) { spl_autoload_register ( array ( $ this , 'autoload' ) , true , true ) ; } else { spl_autoload_register ( array ( $ this , 'autoload' ) , true ) ; } }
Register the autoloader with spl_autoload registry
46,790
protected function loadMapFromFile ( $ location ) { if ( ! file_exists ( $ location ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( 'Map file provided does not exist' ) ; } if ( ! $ path = self :: realPharPath ( $ location ) ) { $ path = realpath ( $ location ) ; } if ( in_array ( $ path , $ this -> mapsLoaded ) ) { return $ this ; } $ map = include $ path ; return $ map ; }
Load a map from a file
46,791
public static function resolvePharParentPath ( $ value , $ key , & $ parts ) { if ( $ value !== '...' ) { return ; } unset ( $ parts [ $ key ] , $ parts [ $ key - 1 ] ) ; $ parts = array_values ( $ parts ) ; }
Helper callback to resolve a parent path in a Phar archive
46,792
public function setCallback ( callable $ callback , array $ params = [ ] ) { if ( $ this -> hasCallback ( ) ) { throw new ArchException ( 'Callback already defined' ) ; } $ this -> callback = $ callback ; $ this -> callbackParams = $ params ; return $ this ; }
Define the callback function . This function need to send a content feed on standard output . This callback is usefull to bypass the body in order to optimize performances .
46,793
protected function _getTermTypeRenderer ( $ termType , $ context = null ) { $ container = $ this -> _getTermTypeRendererContainer ( ) ; return $ this -> _containerGet ( $ container , $ termType ) ; }
Retrieves the renderer for a given term .
46,794
protected function ensureFileIsReadable ( ) { $ filePath = $ this -> filePath ; if ( ! is_readable ( $ filePath ) || ! is_file ( $ filePath ) ) { throw new InvalidArgumentException ( sprintf ( 'Dotenv: Environment file .env not found or not readable. ' . 'Create file with your environment settings at %s' , $ filePath ) ) ; } }
Ensures the given filePath is readable .
46,795
protected function normaliseEnvironmentVariable ( $ name , $ value ) { list ( $ name , $ value ) = $ this -> splitCompoundStringIntoParts ( $ name , $ value ) ; return array ( $ name , $ value ) ; }
Normalise the given environment variable .
46,796
protected function readLinesFromFile ( $ filePath ) { $ autodetect = ini_get ( 'auto_detect_line_endings' ) ; ini_set ( 'auto_detect_line_endings' , '1' ) ; $ lines = file ( $ filePath , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ; ini_set ( 'auto_detect_line_endings' , $ autodetect ) ; return $ lines ; }
Read lines from the file auto detecting line endings .
46,797
public function getName ( $ suffix = NULL ) : string { $ name = $ suffix ? basename ( $ this -> path , $ suffix ) : basename ( $ this -> path ) ; return $ name ; }
Name of the file or directory
46,798
public function putContents ( $ contents , $ ex_lock = false ) : int { $ flags = $ ex_lock ? LOCK_EX : 0 ; $ res = file_put_contents ( $ this -> path , $ contents , $ flags ) ; if ( $ res === FALSE ) { throw new FileOutputException ( $ this ) ; } return $ res ; }
Save string data as a file
46,799
public function rename ( $ new_file ) { $ res = @ rename ( $ this -> path , $ new_file -> getPath ( ) ) ; if ( $ res === FALSE ) { throw new FileRenameException ( $ this , $ new_file ) ; } }
Rename the file or directory