idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
50,900
public function read ( Request $ request ) { if ( ! $ request -> cookies -> has ( $ this -> cookieSettings -> getName ( ) ) ) { return null ; } return $ this -> createCookieWithValue ( $ request -> cookies -> get ( $ this -> cookieSettings -> getName ( ) ) ) ; }
Retrieve the current cookie from the Request if it exists .
50,901
public function redirect ( $ to , $ full = false ) { $ to = trim ( $ to , '/' ) ; if ( ! $ full && ! Str :: startsWith ( App :: $ Alias -> baseUrl , $ to ) ) { $ to = App :: $ Alias -> baseUrl . '/' . $ to ; } $ redirect = new FoundationRedirect ( $ to ) ; $ redirect -> send ( ) ; exit ( 'Redirecting to ' . $ to . ' .....
Fast redirect in web environment
50,902
public function connect ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'CONNECT' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in CONNECT HTTP method .
50,903
public function delete ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'DELETE' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in DELETE HTTP method .
50,904
public function get ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'GET' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in GET HTTP method .
50,905
public function head ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'HEAD' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in HEAD HTTP method .
50,906
public function options ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'OPTIONS' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in OPTIONS HTTP method .
50,907
public function patch ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'PATCH' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in PATCH HTTP method .
50,908
public function post ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'POST' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in POST HTTP method .
50,909
public function purge ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'PURGE' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in PURGE HTTP method .
50,910
public function put ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'PUT' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in PUT HTTP method .
50,911
public function trace ( $ uri , $ handler , $ middlewares = array ( ) ) { return $ this -> add ( $ this -> route ( 'TRACE' , $ uri , $ handler , $ middlewares ) ) ; }
Adds a new route instance in TRACE HTTP method .
50,912
protected function route ( $ method , $ uri , $ handler , $ middlewares ) { if ( is_string ( $ handler ) === true ) { $ namespace = $ this -> namespace ; $ namespace !== '' && $ namespace .= '\\' ; $ handler = $ namespace . $ handler ; } return new Route ( $ method , $ uri , $ handler , $ middlewares ) ; }
Prepares a new route instance .
50,913
protected function getSentry ( Container $ container ) : callable { return function ( $ c ) { $ config = $ c [ 'config' ] ( 'suit.sentry' ) ; $ client = new \ Raven_Client ( $ config [ 'dsn' ] , $ config [ 'options' ] ?? [ ] ) ; $ client -> install ( ) ; if ( $ c -> has ( 'user' ) ) { $ client -> user_context ( ( array...
Add Sentry integration .
50,914
protected function setErrorHandler ( Container $ container ) : callable { return function ( Container $ container ) { return function ( ServerRequestInterface $ request , ResponseInterface $ response , Throwable $ e ) use ( $ container ) { $ container -> sentry -> captureException ( $ e ) ; if ( $ container -> has ( 'a...
Set error handler with sentry .
50,915
protected function prepare ( array $ product ) { $ data = array ( ) ; foreach ( $ this -> job [ 'data' ] [ 'header' ] as $ key => $ value ) { $ data [ $ key ] = isset ( $ product [ $ key ] ) ? $ product [ $ key ] : '' ; } $ this -> prepareImages ( $ data , $ product ) ; $ this -> preparePrice ( $ data , $ product ) ; $...
Prepares export data
50,916
public function up ( $ limit = 0 ) { $ migrations = $ this -> getNewMigrations ( ) ; if ( empty ( $ migrations ) ) { $ this -> messages [ ] = 'No new migration found. Your system is up-to-date.' ; return true ; } foreach ( $ migrations as $ migration ) { if ( ! $ this -> migrateUp ( $ migration ) ) { $ this -> messages...
Upgrades the application by applying new migrations .
50,917
protected function migrateUp ( $ class ) { if ( $ class === self :: BASE_MIGRATION ) { return true ; } $ this -> messages [ ] = "*** applying $class" ; $ start = microtime ( true ) ; $ migration = $ this -> createMigration ( $ class ) ; ob_start ( ) ; $ result = $ migration -> up ( ) ; $ messages = ob_get_contents ( ) ...
Upgrades with the specified migration class .
50,918
protected function getMigrationHistory ( $ limit ) { if ( $ this -> db -> schema -> getTableSchema ( $ this -> migrationTable , true ) === null ) { $ this -> createMigrationHistoryTable ( ) ; } $ query = new Query ; $ rows = $ query -> select ( [ 'version' , 'apply_time' ] ) -> from ( $ this -> migrationTable ) -> orde...
Returns the migration history .
50,919
public function locate ( $ source ) { $ sources = [ ] ; $ normalizedSources = [ ] ; $ endingWithWilCard = substr ( $ source , strlen ( $ source ) - 2 ) === '/*' ; if ( $ endingWithWilCard ) { $ source = substr ( $ source , 0 , strlen ( $ source ) - 2 ) ; } if ( is_dir ( $ source ) || $ endingWithWilCard ) { $ finder = ...
Locate a source either if it a file or a directory and normalize it . Return an array of SplFileInfo .
50,920
protected function getSourcesFromFinder ( $ source ) { $ array = explode ( DIRECTORY_SEPARATOR , $ source ) ; $ filename = array_pop ( $ array ) ; $ directory = $ source ; $ pattern = '*' ; if ( strstr ( $ filename , '.' ) !== false ) { $ pattern = $ filename ; $ directory = implode ( '/' , $ array ) ; } $ finder = new...
Return files sources using the finder to allow wild wards .
50,921
private function removeLastSlash ( $ string ) { if ( '/' === substr ( $ string , strlen ( $ string ) - 1 ) ) { $ string = substr ( $ string , 0 , strlen ( $ string ) - 1 ) ; } return $ string ; }
Remove the last slash of the string .
50,922
public function SetContent ( Content $ content ) { $ this -> texts = array ( ) ; $ wordings = ContentWording :: Schema ( ) -> FetchByContent ( false , $ content ) ; foreach ( $ wordings as $ wording ) { $ prefix = Str :: Replace ( '-' , '.' , $ content -> GetType ( ) ) ; $ this -> texts [ $ prefix . '.' . $ wording -> ...
Set the current content to retrieve customized wording texts
50,923
public function GetReplacement ( $ placeholder ) { if ( isset ( $ this -> texts [ $ placeholder ] ) ) { return $ this -> texts [ $ placeholder ] ; } return $ this -> phpTranslator -> GetReplacement ( $ placeholder ) ; }
Gets the placeholder replacement text
50,924
public function decodePair ( string $ keyValuePair ) : array { if ( strpos ( $ keyValuePair , "+" ) !== false ) { $ keyValuePair = str_replace ( "+" , " " , $ keyValuePair ) ; } $ parts = explode ( "=" , $ keyValuePair , 2 ) ; $ key = rawurldecode ( $ parts [ 0 ] ) ; $ value = ( count ( $ parts ) === 1 ) ? null : rawur...
Decode a urlencoded parameter key value pair
50,925
public function decode ( $ query ) : array { foreach ( explode ( "&" , $ query ) as $ keyValuePair ) { list ( $ key , $ value ) = $ this -> decodePair ( $ keyValuePair ) ; $ this -> values -> addValue ( $ key , $ value ) ; } return $ this -> values -> getValues ( ) ; }
Decode a query string
50,926
public function crossJoin ( $ table , $ first = null , $ operator = null , $ second = null ) { if ( $ first ) { return $ this -> join ( $ table , $ first , $ operator , $ second , 'cross' ) ; } $ this -> joins [ ] = new JoinClause ( 'cross' , $ table ) ; return $ this ; }
Add a cross join clause to the query .
50,927
public function lock ( $ value = true ) { $ this -> lock = $ value ; if ( $ this -> lock ) { $ this -> useWritePdo ( ) ; } return $ this ; }
Lock the selected rows in the table .
50,928
public function getMemberUsers ( ) { $ memberTable = CmnTables :: getTableName ( CmnTables :: TABLE_GROUP_MEMBER ) ; return $ this -> hasMany ( User :: class , [ 'id' => 'userId' ] ) -> viaTable ( $ memberTable , [ 'groupId' => 'id' ] ) ; }
Return all the group member users .
50,929
public static function queryWithAuthor ( $ config = [ ] ) { $ config [ 'relations' ] [ ] = [ 'avatar' , 'modelContent' , 'modelContent.template' , 'modelContent.banner' , 'creator' ] ; $ config [ 'relations' ] [ ] = [ 'creator.avatar' => function ( $ query ) { $ fileTable = CoreTables :: getTableName ( CoreTables :: TA...
Return query to find the model with avatar content template banner author and author avatar .
50,930
public function addResourceItem ( ProductionMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ group = $ event -> getGroup ( ) ; $ resources = $ this -> factory -> createItem ( 'menu_item.resources' , [ 'route' => 'bkstg_resource_index' , 'routeParameters' => [ 'production_slug' => $ group -> ge...
Add the resource menu items .
50,931
public function render ( ) { $ allMessages = [ 'danger' => array_unique ( array_merge ( $ this -> flashMessenger -> getErrorMessages ( ) , $ this -> flashMessenger -> getCurrentErrorMessages ( ) ) ) , 'success' => array_unique ( array_merge ( $ this -> flashMessenger -> getSuccessMessages ( ) , $ this -> flashMessenger...
Outputs message depending on flag
50,932
public function getInlinedHtml ( $ body ) { $ inliner = new \ TijsVerkoyen \ CssToInlineStyles \ CssToInlineStyles ; $ inliner -> setHtml ( $ body ) ; $ inliner -> setUseInlineStylesBlock ( ) ; return $ inliner -> convert ( ) ; }
sets body after mashing in inline styles this is the method for doing tagging simple now!
50,933
final public function execute ( $ bound_input_params = null ) { if ( ! is_array ( $ bound_input_params ) or empty ( $ bound_input_params ) ) { $ success = parent :: execute ( ) ; } else { $ success = parent :: execute ( $ this -> bindConversion ( $ bound_input_params ) ) ; } if ( is_null ( $ this -> _success ) ) { $ th...
Execute the prepared statement
50,934
public function getLogFiles ( $ count = 20 ) { $ files = glob ( storage_path ( 'logs/*' ) ) ; $ files = array_combine ( $ files , array_map ( "filemtime" , $ files ) ) ; arsort ( $ files ) ; $ files = array_map ( 'basename' , array_keys ( $ files ) ) ; return array_slice ( $ files , 0 , $ count ) ; }
Get log file list in storage .
50,935
public function getPrevPageUrl ( ) { if ( $ this -> pageOffset [ 'end' ] >= $ this -> getFilesize ( ) - 1 ) { return false ; } return [ 'file' => $ this -> file , 'offset' => $ this -> pageOffset [ 'end' ] ] ; }
Get previous page url .
50,936
public function tail ( $ seek ) { $ f = fopen ( $ this -> filePath , "rb" ) ; if ( ! $ seek ) { fseek ( $ f , - 1 , SEEK_END ) ; } else { fseek ( $ f , abs ( $ seek ) ) ; } $ output = '' ; while ( ! feof ( $ f ) ) { $ output .= fread ( $ f , 4096 ) ; } $ pos = ftell ( $ f ) ; fclose ( $ f ) ; $ logs = [ ] ; foreach ( $...
Get tail logs in log file .
50,937
protected function renderTableRow ( $ log ) { $ color = LogViewer :: $ levelColors [ $ log [ 'level' ] ] ?? 'black' ; $ index = uniqid ( ) ; $ button = '' ; if ( ! empty ( $ log [ 'trace' ] ) ) { $ button = "<a class=\"btn btn-primary btn-xs\" data-toggle=\"collapse\" data-target=\".trace-{$index}\"><i class=\"fa fa-in...
Render table row .
50,938
public function setMedia ( ChildMedia $ v = null ) { if ( $ v === null ) { $ this -> setMediaId ( NULL ) ; } else { $ this -> setMediaId ( $ v -> getId ( ) ) ; } $ this -> aMedia = $ v ; if ( $ v !== null ) { $ v -> addM2P ( $ this ) ; } return $ this ; }
Declares an association between this object and a ChildMedia object .
50,939
public function getMedia ( ConnectionInterface $ con = null ) { if ( $ this -> aMedia === null && ( $ this -> media_id != 0 ) ) { $ this -> aMedia = ChildMediaQuery :: create ( ) -> findPk ( $ this -> media_id , $ con ) ; } return $ this -> aMedia ; }
Get the associated ChildMedia object
50,940
public function setPage ( ChildPage $ v = null ) { if ( $ v === null ) { $ this -> setPageId ( NULL ) ; } else { $ this -> setPageId ( $ v -> getId ( ) ) ; } $ this -> aPage = $ v ; if ( $ v !== null ) { $ v -> addM2P ( $ this ) ; } return $ this ; }
Declares an association between this object and a ChildPage object .
50,941
public function getPage ( ConnectionInterface $ con = null ) { if ( $ this -> aPage === null && ( $ this -> page_id != 0 ) ) { $ this -> aPage = ChildPageQuery :: create ( ) -> findPk ( $ this -> page_id , $ con ) ; } return $ this -> aPage ; }
Get the associated ChildPage object
50,942
public static function determinePlugins ( $ packages , $ pluginsDir = 'plugins' , $ vendorDir = 'vendor' ) { $ plugins = [ ] ; foreach ( $ packages as $ package ) { if ( $ package -> getType ( ) !== 'skinny-plugin' ) { continue ; } $ ns = static :: primaryNamespace ( $ package ) ; $ path = $ vendorDir . DIRECTORY_SEPAR...
Find all plugins available .
50,943
public static function writeConfigFile ( $ configFile , $ plugins , $ root = null ) { $ root = $ root ? : dirname ( dirname ( $ configFile ) ) ; $ data = [ ] ; foreach ( $ plugins as $ name => $ pluginPath ) { $ pluginPath = str_replace ( '\\' , '/' , $ pluginPath ) ; $ pluginPath .= '/' ; $ pluginPath = str_replace ( ...
Rewrite the config file with a complete list of plugins .
50,944
public static function primaryNamespace ( $ package ) { $ primaryNs = null ; $ autoLoad = $ package -> getAutoload ( ) ; foreach ( $ autoLoad as $ type => $ pathMap ) { if ( $ type !== 'psr-4' ) { continue ; } $ count = count ( $ pathMap ) ; if ( $ count === 1 ) { $ primaryNs = key ( $ pathMap ) ; break ; } $ matches =...
Get the primary namespace for a plugin package .
50,945
public function install ( InstalledRepositoryInterface $ repo , PackageInterface $ package ) { parent :: install ( $ repo , $ package ) ; $ path = $ this -> getInstallPath ( $ package ) ; $ ns = static :: primaryNamespace ( $ package ) ; $ this -> updateConfig ( $ ns , $ path ) ; }
Installs specific plugin .
50,946
public function update ( InstalledRepositoryInterface $ repo , PackageInterface $ initial , PackageInterface $ target ) { parent :: update ( $ repo , $ initial , $ target ) ; $ ns = static :: primaryNamespace ( $ initial ) ; $ this -> updateConfig ( $ ns , null ) ; $ path = $ this -> getInstallPath ( $ target ) ; $ ns ...
Updates specific plugin .
50,947
public function updateConfig ( $ name , $ path ) { $ name = str_replace ( '\\' , '/' , $ name ) ; $ configFile = static :: configFile ( $ this -> vendorDir ) ; $ this -> ensureConfigFile ( $ configFile ) ; $ return = include $ configFile ; if ( is_array ( $ return ) && empty ( $ config ) ) { $ config = $ return ; } if ...
Update the plugin path for a given package .
50,948
protected function _modify ( ) { $ this -> _table -> alter ( 'MODIFY ' . $ this -> _database -> prepareIdentifier ( $ this -> _name ) . ' ' . $ this -> getDefinition ( ) ) ; }
Modify column in the database according to current properties
50,949
public function saveRoles ( $ inputRoles ) { if ( ! empty ( $ inputRoles ) ) { $ this -> roles ( ) -> sync ( $ inputRoles ) ; } else { $ this -> roles ( ) -> detach ( ) ; } }
Save the inputted roles .
50,950
private function extractEntry ( $ class ) { if ( $ class != $ this -> baseClass && ! is_subclass_of ( $ class , $ this -> baseClass ) ) { return false ; } if ( ! preg_match_all ( '~/?([a-zA-Z0-9]+)~' , $ class , $ namespaces ) ) { throw new \ Exception ( "Unexpected class {$class}." ) ; } $ prefix = $ suffix = null ; $...
Extracts the discriminator name from the given class .
50,951
public function validateAttribute ( $ model , $ attribute ) { $ value = $ model -> $ attribute ; $ result = $ this -> validateValue ( $ value ) ; if ( ! empty ( $ result ) ) { $ this -> addError ( $ model , $ attribute , $ this -> renderMessage ( $ model , $ attribute ) ) ; } }
Validates a single attribute .
50,952
private function renderMessage ( $ model , $ attribute ) { $ attributeLabel = $ model -> getAttributeLabel ( $ attribute ) ; $ message = strtr ( $ this -> message , [ '{attribute}' => $ attributeLabel ] ) ; return $ message ; }
Renders the attribute s error message .
50,953
public function findQuery ( $ strQuery ) { foreach ( $ this -> queries as $ query ) { if ( $ query -> matches ( $ strQuery ) ) { return $ query ; } } return null ; }
Try to find the query matching the given string .
50,954
public static function register ( $ action , $ closure ) { if ( false === is_string ( $ action ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ action ) ) , E_USER_ERROR ) ; } if ( false === is_object ( $ closure ) ) { return trigger_er...
Register a new template function
50,955
public function getException ( $ code ) { if ( ! isset ( $ this -> exceptions [ $ code ] ) ) { throw new Exceptions \ ExceptionNotDefinedException ( $ this , $ code ) ; } return $ this -> exceptions [ $ code ] ; }
Retrieve an exception class given code .
50,956
public function setColors ( $ textColor = null , $ fillColor = null ) { $ this -> desiredState -> setTextColor ( $ textColor ) ; $ this -> desiredState -> setFillColor ( $ fillColor ) ; return $ this ; }
Set both the fill and text colors
50,957
public function clear ( $ rightAway = false ) { $ this -> desiredState -> clear ( ) ; if ( $ rightAway ) { $ this -> output ( EscapeSequenceGenerator :: generateClearSequence ( ) ) ; $ this -> currentState = new TerminalState ( ) ; $ this -> desiredState = new TerminalState ( ) ; } return $ this ; }
Clear away all formatting - bold underscore text and fill color
50,958
public function outputEscapeSequence ( ) { $ this -> output ( $ this -> generator -> generate ( $ this -> currentState , $ this -> desiredState ) ) ; $ this -> currentState = clone $ this -> desiredState ; }
Send out the escape sequence which will accomplish the desired state
50,959
public function newLine ( $ count = 1 ) { $ this -> outputEscapeSequence ( ) ; if ( is_int ( $ count ) && $ count > 1 ) { for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ this -> output ( "\n" ) ; } } else { $ this -> output ( "\n" ) ; } $ this -> carriageReturn ( ) ; return $ this ; }
Move the cursor to the next line This is not an ANSI sequence but rather the ASCII code 12 or \ n
50,960
public function clearScreen ( ) { $ this -> outputEscapeSequence ( ) ; $ this -> output ( EscapeSequenceGenerator :: generateClearScreenSequence ( ) ) ; $ this -> carriageReturn ( ) ; return $ this ; }
Clear the screen and move cursor to the top .
50,961
public function prompt ( $ text ) { $ this -> outputEscapeSequence ( ) ; $ prompt = $ text . $ this -> promptCaret . " " ; return $ this -> readUserInput ( $ prompt ) ; }
Prompt for a value .
50,962
public static function getScreenHeight ( ) { set_error_handler ( "self::errorHandler" , E_WARNING ) ; $ output = [ ] ; $ height = exec ( "tput lines 2>&1" , $ output ) ; if ( $ height == 0 || $ height == "" || is_null ( $ height ) ) { self :: errorHandler ( null , null ) ; } restore_error_handler ( ) ; return intval ( ...
Get the current screen height
50,963
public static function getScreenWidth ( ) { set_error_handler ( "self::errorHandler" , E_WARNING ) ; $ output = [ ] ; $ width = exec ( "tput cols 2>&1" , $ output ) ; if ( count ( $ output ) == 0 || $ width == 0 || $ width == "" || is_null ( $ width ) ) { self :: errorHandler ( null , null ) ; } restore_error_handler (...
Get the current screen width
50,964
public function sendContent ( ) { if ( ! $ this -> isSuccessful ( ) ) { return parent :: sendContent ( ) ; } if ( 0 === $ this -> maxlen ) { return $ this ; } $ out = fopen ( 'php://output' , 'wb' ) ; $ in = $ this -> resource -> getStream ( ) ; stream_copy_to_stream ( $ in , $ out , $ this -> maxlen , $ this -> offset...
Sends the resource .
50,965
public function open ( $ options = [ ] ) { $ options [ 'method' ] = self :: getMethod ( $ options ) ; $ options [ 'action' ] = self :: getAction ( $ options ) ; $ options [ 'accept-charset' ] = 'UTF-8' ; if ( isset ( $ options [ 'files' ] ) && $ options [ 'files' ] ) { $ options [ 'enctype' ] = 'multipart/form-data' ; ...
Open a new form object .
50,966
public function input ( $ type , $ name , $ value = '' , $ options = [ ] ) { if ( ! isset ( $ options [ 'id' ] ) ) { $ options [ 'id' ] = $ name ; } if ( ! empty ( $ value ) ) { $ options [ 'value' ] = $ value ; } $ options [ 'type' ] = $ type ; $ options [ 'name' ] = $ name ; return '<input' . $ this -> attributes ( $...
Creates a form input element .
50,967
public function textarea ( $ name , $ value = '' , $ options = [ ] ) { if ( ! isset ( $ options [ 'id' ] ) ) { $ options [ 'id' ] = $ name ; } $ options [ 'name' ] = $ name ; return '<textarea' . $ this -> attributes ( $ options ) . '>' . $ value . '</textarea>' ; }
Creates a textarea form input box .
50,968
private function getAction ( $ options ) { if ( isset ( $ options [ 'action' ] ) ) { $ action = $ this -> _generator -> to ( $ options [ 'action' ] ) ; } else { $ action = $ _SERVER [ 'REQUEST_URI' ] ; } return $ action ; }
Gets the form action .
50,969
private function getId ( $ options ) { $ id = '' ; if ( ! isset ( $ options [ 'id' ] ) ) { $ id = $ options [ 'name' ] ; } else { $ id = $ options [ 'id' ] ; } return $ id ; }
Gets an input s id or sets it if not supplied .
50,970
public function createStreamFromArray ( array $ params ) { $ string = "" ; foreach ( $ params as $ key => $ value ) { $ string .= $ key . '=' . urlencode ( trim ( $ value ) ) . '&' ; } $ string = rtrim ( $ string , "&" ) ; return $ this -> createStream ( $ string ) ; }
Helper method to create a string stream from given array .
50,971
public function callMethod ( $ name , $ httpMethod = "POST" , $ params = array ( ) , $ payload = null , $ returnClass = null , $ expectedExceptions = null ) { $ objectToFormatConverter = $ this -> dataFormat == self :: DATA_FORMAT_JSON ? new ObjectToJSONConverter ( ) : new ObjectToXMLConverter ( ) ; $ formatToObjectCon...
Implement the call method to call a proxy service
50,972
public function setTemplateFile ( string $ sRelativePathToFile ) : void { if ( ! is_file ( $ sRelativePathToFile ) ) { throw new \ Exception ( 'Template file not found.' ) ; } $ sFileContent = file_get_contents ( $ sRelativePathToFile ) ; $ this -> setTemplate ( $ sFileContent ) ; }
This method is used to set the template from a relative path .
50,973
public function render ( ) : string { $ sOutput = preg_replace_callback ( '/{(.*?)}/' , function ( $ aResult ) { $ aToSearch = explode ( '.' , $ aResult [ 1 ] ) ; $ aSearchIn = $ this -> getData ( ) ; foreach ( $ aToSearch as $ sKey ) { list ( $ sFormattedKey , $ mParam ) = self :: getFunctionNameAndParameter ( $ sKey ...
This method replaces the placeholders in the template string with the values from the data object and returns the new string .
50,974
private function safelyReadData ( $ path ) { $ fp = fopen ( $ path , 'r' ) ; $ retries = 0 ; do { if ( $ retries > 0 ) { usleep ( static :: MS_BETWEEN_RETRIES * 1000 ) ; } $ retries ++ ; } while ( ! flock ( $ fp , LOCK_SH | LOCK_NB ) && $ retries <= static :: MAX_RETRIES ) ; if ( $ retries == static :: MAX_RETRIES ) { ...
Safely read data from a file
50,975
private function safelyWriteData ( $ path , $ mode , $ data ) { $ fp = fopen ( $ path , $ mode ) ; $ retries = 0 ; if ( empty ( $ fp ) ) { return false ; } do { if ( $ retries > 0 ) { usleep ( static :: MS_BETWEEN_RETRIES * 1000 ) ; } $ retries ++ ; } while ( ! flock ( $ fp , LOCK_EX ) && $ retries <= static :: MAX_RET...
Safely write data to a file
50,976
protected function processKey ( $ key ) { $ key = trim ( strtolower ( $ key ) ) ; $ key = preg_replace ( '#[^a-z0-9\.]#' , '-' , $ key ) . '~' . $ this -> keySuffix ; return $ key ; }
Process the key to be filename safe
50,977
protected function closePrevious ( ) { static $ previous = [ ] ; $ id = spl_object_hash ( $ this -> getDriver ( ) ) ; if ( isset ( $ previous [ $ id ] ) && $ previous [ $ id ] !== $ this -> prepared ) { $ this -> realClose ( $ previous [ $ id ] ) ; } $ previous [ $ id ] = $ this -> prepared ; return $ this ; }
Close previous prepared statement
50,978
protected function setError ( $ resource ) { if ( is_string ( $ resource ) ) { $ this -> getDriver ( ) -> setError ( $ resource , - 1 ) ; } else { $ this -> getDriver ( ) -> setError ( $ this -> realError ( $ resource ) , $ this -> realErrorCode ( $ resource ) ) ; } }
Set driver error
50,979
public static function createGeocodingProvider ( $ provider_code = GeocodingProviders :: GOOGLE_MAPS ) { if ( GeocodingProviders :: GOOGLE_MAPS != $ provider_code ) { throw new GeocodingException ( 'Geocoding provider \'' . $ provider_code . '\' not found.' ) ; } return new \ BlueBlazeAssociates \ Geocoding \ PostalCod...
Creates a geocoding provider based on a set code .
50,980
public static function createGeocoder ( $ country_code = CountryCodes :: US , $ provider_code = GeocodingProviders :: GOOGLE_MAPS ) { if ( CountryCodes :: US != $ country_code ) { throw new GeocodingException ( 'PostalCode geocoder for country \'' . $ country_code . '\' not found.' ) ; } $ geocoding_provider = static :...
Create a country specific geocoder for postal codes .
50,981
public static function create ( array $ parameters , Configuration $ configuration = null ) { if ( isset ( $ parameters [ 'driver_class' ] ) ) { if ( ! in_array ( 'Fridge\DBAL\Driver\DriverInterface' , class_implements ( $ parameters [ 'driver_class' ] ) ) ) { throw FactoryException :: driverMustImplementDriverInterfac...
Creates a DBAL connection .
50,982
public function getName ( ) { switch ( $ this -> ofWeek ) { case Carbon :: MONDAY : $ name = 'Monday' ; break ; case Carbon :: TUESDAY : $ name = 'Tuesday' ; break ; case Carbon :: WEDNESDAY : $ name = 'Wednesday' ; break ; case Carbon :: THURSDAY : $ name = 'Thursday' ; break ; case Carbon :: FRIDAY : $ name = 'Friday...
Gets the day s name .
50,983
public function get ( $ name ) { if ( isset ( $ this -> items [ $ name ] ) ) { return $ this -> items [ $ name ] ; } if ( ! isset ( $ this -> itemSetting [ $ name ] ) ) { return null ; } $ itemSetting = $ this -> itemSetting [ $ name ] ; if ( is_callable ( $ itemSetting ) ) { $ item = $ itemSetting ( ) ; } elseif ( is_...
Get an item from container
50,984
public function set ( $ name , $ value = null ) { $ values = is_array ( $ name ) ? $ name : [ $ name => $ value ] ; foreach ( $ values as $ name => $ value ) { $ this -> itemSetting [ $ name ] = $ value ; } unset ( $ this -> items [ $ name ] ) ; }
Set one or multiple items or factory function of items or class of items into DI container .
50,985
public function setRouting ( array $ routings = [ ] ) { $ this -> dispatcher = null ; $ this -> routings = $ routings + $ this -> routings ; foreach ( $ this -> routings as $ name => & $ routing ) { if ( 1 == count ( $ routing ) ) { array_unshift ( $ routing , '/' . ltrim ( $ name , '/' ) ) ; } if ( 2 == count ( $ rout...
Set app routing .
50,986
public function handlerAlias ( $ name , $ value = null ) { $ alias = is_array ( $ name ) ? $ name : [ $ name => $ value ] ; $ this -> handlerAlias = $ alias + $ this -> handlerAlias ; }
Set alias name for request handlers
50,987
public function route ( $ method , $ uri ) { $ baseDir = $ this -> get ( ' .baseDir' ) ; if ( "/" !== $ baseDir && 0 === strpos ( $ uri , $ baseDir ) ) { $ uri = substr ( $ uri , strlen ( $ baseDir ) ) ; } $ routings = $ this -> routings ; $ this -> dispatcher = $ this -> dispatcher ? : \ FastRoute \ simpleDispatcher (...
Determin which route to use and parameters in uri .
50,988
private function patternToPath ( $ pattern , $ params ) { $ routeParser = new RouteParserStd ; $ routes = $ routeParser -> parse ( $ pattern ) ; for ( $ i = count ( $ routes ) - 1 ; $ i >= 0 ; $ i -- ) { $ url = '' ; foreach ( $ routes [ $ i ] as $ part ) { if ( is_array ( $ part ) ) { $ part = @ $ params [ $ part [ 0 ...
Convert url pattern to actual path
50,989
public function run ( $ options = [ ] ) { $ method = @ $ options [ 'method' ] ? : $ _SERVER [ 'REQUEST_METHOD' ] ; $ uri = @ $ options [ 'uri' ] ? : rawurldecode ( $ _SERVER [ 'REQUEST_URI' ] ) ; if ( false !== $ pos = strpos ( $ uri , '?' ) ) { $ uri = substr ( $ uri , 0 , $ pos ) ; } $ routeInfo = $ this -> route ( $...
Entry point for application
50,990
public function runAs ( $ routeName , $ params = [ ] ) { if ( ! isset ( $ this -> routings [ $ routeName ] ) ) { throw new \ Exception ( "Route name '{$routeName}' not found!" ) ; } $ handler = end ( $ this -> routings [ $ routeName ] ) ; $ this -> appendHandlerQueue ( $ handler ) ; $ output = null ; while ( $ handler ...
Handle current request using specificed route handler
50,991
public function executeHandler ( $ handler , $ params , $ prevOutput = null ) { if ( is_callable ( $ handler ) ) { return $ handler ( $ this , $ params , $ prevOutput ) ; } if ( $ actualHandler = @ $ this -> handlerAlias [ $ handler ] ) { return $ this -> executeHandler ( $ actualHandler , $ params , $ prevOutput ) ; }...
Parse and execute request handler
50,992
public function hashCode ( ) { $ h = $ this -> hash ; $ l = $ this -> length ( ) ; if ( $ h == 0 && $ l > 0 ) { for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { $ h = ( int ) ( 31 * $ h + $ this -> charCodeAt ( $ i ) ) ; } $ this -> hash = $ h ; } return $ h ; }
Returns a hash code for this string .
50,993
public function indexOf ( $ sequence , $ fromIndex = 0 , $ ignoreCase = false ) { if ( $ fromIndex < 0 ) { $ fromIndex = 0 ; } else if ( $ fromIndex >= $ this -> length ( ) ) { return - 1 ; } if ( $ ignoreCase == false ) { $ index = strpos ( $ this -> value , $ sequence , $ fromIndex ) ; } else { $ index = stripos ( $ ...
Returns the index within this string of the first occurrence of the specified string optionally starting the search at the specified index .
50,994
public function lastIndexOf ( $ sequence , $ fromIndex = 0 , $ ignoreCase = false ) { if ( $ fromIndex < 0 ) { $ fromIndex = 0 ; } else if ( $ fromIndex >= $ this -> length ( ) ) { return - 1 ; } if ( $ ignoreCase == false ) { $ index = strrpos ( $ this -> value , $ sequence , $ fromIndex ) ; } else { $ index = strripo...
Returns the index within this string of the last occurrence of the specified string searching backward starting at the specified index .
50,995
public function matches ( $ regex , & $ matches = null ) { $ match = preg_match ( $ regex , $ this -> value , $ matches ) ; for ( $ i = 0 , $ l = count ( $ matches ) ; $ i < $ l ; $ i ++ ) { $ matches [ $ i ] = new GString ( $ matches [ $ i ] ) ; } return $ match == 1 ; }
Tells whether or not this string matches the given regular expression .
50,996
public function padLeft ( $ length , $ padString ) { return new GString ( str_pad ( $ this -> value , $ length , $ padString , STR_PAD_LEFT ) ) ; }
Returns the left padded string to a certain length with the specified string .
50,997
public function padRight ( $ length , $ padString ) { return new GString ( str_pad ( $ this -> value , $ length , $ padString , STR_PAD_RIGHT ) ) ; }
Returns the right padded string to a certain length with the specified string .
50,998
public function regionCompare ( $ offseta , $ str , $ offsetb , $ length , $ ignoreCase = false ) { $ a = $ this -> substring ( $ offseta ) ; $ b = new GString ( $ str ) ; $ b = $ b -> substring ( $ offsetb ) ; if ( $ ignoreCase == false ) { return strncmp ( $ a , $ b , $ length ) ; } else { return strncasecmp ( $ a , ...
Compare two string regions .
50,999
public function regionCompareIgnoreCase ( $ offseta , $ str , $ offsetb , $ length ) { return $ this -> regionCompare ( $ offseta , $ str , $ offsetb , $ length , true ) ; }
Compare two string regions ignoring case differences .