idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
59,700
public function addError ( OperationError $ ex , bool $ stopPropagation = false ) { $ this -> lastError = $ ex ; if ( $ stopPropagation ) { $ this -> stopPropagation ( ) ; } }
Adds an OperationError to the operation events error list .
59,701
public function setResults ( $ results = null , bool $ stopPropagation = false ) { $ this -> result = $ results ; if ( $ stopPropagation ) { $ this -> stopPropagation ( ) ; } }
Sets the operations result .
59,702
public function query ( $ query , $ params = null , $ fetchResult = false ) { $ this -> checkConnection ( true ) ; $ this -> log ( 'Query: ' . $ query ) ; if ( ! empty ( $ params ) ) { $ this -> log ( 'Params: ' . print_r ( $ params , true ) ) ; } $ start = microtime ( true ) ; if ( empty ( $ params ) ) { $ res = $ thi...
Execute a query and return the results
59,703
protected function executeQuery ( $ query ) { $ res = @ odbc_exec ( $ this -> _lnk , $ query ) ; if ( ! $ res ) { $ error = odbc_errormsg ( $ this -> _lnk ) ; $ this -> log ( 'Query failed: ' . $ error ) ; throw new Exception ( 'Executing query failed ' . $ error , self :: QUERY_FAILED ) ; } return $ res ; }
Execute a query and returns an ODBC result identifier
59,704
protected function executePreparedStatement ( $ query , $ params ) { $ res = odbc_prepare ( $ this -> _lnk , $ query ) ; if ( ! $ res ) { $ error = odbc_errormsg ( $ this -> _lnk ) ; $ this -> log ( 'Prepare failed: ' . $ error ) ; throw new Exception ( 'Preparing query failed ' . $ error , self :: PREPARE_FAILED ) ; }...
Prepare a query execute it and return an ODBC result identifier
59,705
protected function checkConnection ( $ reconnect = false ) { if ( empty ( $ this -> _lnk ) ) { $ this -> log ( 'CheckConnection: link is not valid' ) ; if ( $ reconnect ) { $ this -> log ( 'CheckConnection: try to reconnect' ) ; $ this -> _lnk = @ odbc_connect ( 'Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SER...
Check if the connection failed and try to reconnect if asked
59,706
public static function decode ( $ cookie ) { $ params = ( array ) json_decode ( base64_decode ( $ cookie ) , true ) ; return new self ( ( string ) array_value ( $ params , 'user_email' ) , ( string ) array_value ( $ params , 'agent' ) , ( string ) array_value ( $ params , 'series' ) , ( string ) array_value ( $ params ...
Decodes an encoded remember me cookie string .
59,707
public function encode ( ) { $ json = json_encode ( [ 'user_email' => $ this -> email , 'agent' => $ this -> userAgent , 'series' => $ this -> series , 'token' => $ this -> token , ] ) ; return base64_encode ( $ json ) ; }
Encodes a remember me cookie .
59,708
public function isValid ( ) { if ( ! filter_var ( $ this -> email , FILTER_VALIDATE_EMAIL ) ) { return false ; } if ( empty ( $ this -> userAgent ) ) { return false ; } if ( empty ( $ this -> series ) ) { return false ; } if ( empty ( $ this -> token ) ) { return false ; } return true ; }
Checks if the cookie contains valid values .
59,709
public function verify ( Request $ req , AuthManager $ auth ) { if ( ! $ this -> isValid ( ) ) { return false ; } if ( $ this -> userAgent != $ req -> agent ( ) ) { return false ; } try { $ userClass = $ auth -> getUserClass ( ) ; $ user = $ userClass :: where ( 'email' , $ this -> email ) -> first ( ) ; } catch ( Mode...
Looks for a remembered user using this cookie from an incoming request .
59,710
public function persist ( UserInterface $ user ) { $ session = new PersistentSession ( ) ; $ session -> email = $ this -> email ; $ session -> series = $ this -> hash ( $ this -> series ) ; $ session -> token = $ this -> hash ( $ this -> token ) ; $ session -> user_id = $ user -> id ( ) ; $ session -> two_factor_verifi...
Persists this cookie to the database .
59,711
function destroy ( ) { $ seriesHash = $ this -> hash ( $ this -> series ) ; PersistentSession :: where ( 'email' , $ this -> email ) -> where ( 'series' , $ seriesHash ) -> delete ( ) ; }
Destroys the persisted cookie in the data store .
59,712
private function hash ( $ token ) { $ app = Application :: getDefault ( ) ; $ salt = $ app [ 'config' ] -> get ( 'app.salt' ) ; return hash_hmac ( 'sha512' , $ token , $ salt ) ; }
Hashes a token .
59,713
protected function getFilesListing ( $ path , array $ params ) { $ files = $ this -> getFiles ( $ path , $ params ) ; return $ this -> prepareFiles ( $ files ) ; }
Returns an array of scanned and prepared files
59,714
protected function prepareFiles ( array $ files ) { $ prepared = array ( ) ; foreach ( $ files as $ file ) { $ type = $ file -> getType ( ) ; $ path = $ file -> getRealPath ( ) ; $ relative_path = gplcart_file_relative ( $ path ) ; $ item = array ( 'info' => $ file , 'type' => $ type , 'path' => $ relative_path , 'owne...
Prepares an array of scanned files
59,715
protected function renderIcon ( array $ item ) { static $ rendered = array ( ) ; if ( isset ( $ rendered [ $ item [ 'extension' ] ] ) ) { return $ rendered [ $ item [ 'extension' ] ] ; } $ template = "file_manager|icons/ext/{$item['extension']}" ; if ( $ item [ 'type' ] === 'dir' ) { $ template = 'file_manager|icons/di...
Returns a rendered icon for the given file extension and type
59,716
protected function isKnownFeed ( ) { if ( empty ( config ( "{$this->configBase}.feeds.{$this->feedName}" ) ) ) { $ this -> warningCount ++ ; Log :: warning ( "The feed referred as '{$this->feedName}' is not configured in the collector " . config ( "{$this->configBase}.collector.name" ) . ' therefore skipping processing...
Check if the feed specified is known in the collector config .
59,717
public function transmute ( $ inFilename , Specification $ targetFormat , $ outFilename ) { $ extractedFile = $ this -> extractor -> extract ( $ inFilename , $ targetFormat ) ; if ( ! $ extractedFile ) { return null ; } $ this -> converter -> convert ( $ extractedFile , $ targetFormat , $ outFilename ) ; return $ outFi...
Transmute file to target format
59,718
public function add ( $ attribute , $ value = array ( ) ) { if ( is_array ( $ attribute ) ) { foreach ( $ attribute as $ k => $ v ) { $ this -> add ( $ k , $ v ) ; } } else { if ( $ attribute instanceof \ Thin \ Html \ Attributes ) { $ this -> add ( $ attribute -> getArray ( ) ) ; } else { $ attribute = strval ( $ attr...
Add an attribute or an array thereof . If the attribute already exists the specified values will be added to it without overwriting the previous ones . Duplicate values are removed .
59,719
public function set ( $ attribute , $ value = array ( ) ) { if ( is_array ( $ attribute ) ) { $ this -> attributes = array ( ) ; foreach ( $ attribute as $ k => $ v ) { $ this -> set ( $ k , $ v ) ; } } else { if ( $ attribute instanceof \ Thin \ Html \ Attributes ) { $ this -> attributes = $ attribute -> getArray ( ) ...
Set the value or values of an attribute or an array thereof . Already existent attributes are overwritten .
59,720
public function remove ( $ attribute , $ value = null ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { if ( null === $ value ) { unset ( $ this -> attributes [ $ attribute ] ) ; } else { $ value = strval ( $ value ) ; foreach ( $ this -> attributes [ $...
Remove an attribute or a value
59,721
public function getArray ( $ attribute = null ) { if ( null === $ attribute ) { return $ this -> attributes ; } else { $ attribute = strval ( $ attribute ) ; if ( ake ( $ attribute , $ this -> attributes ) ) { return $ this -> attributes [ $ attribute ] ; } } return null ; }
Get the entire attributes array or the array of values for a single attribute .
59,722
public function getHtml ( $ attribute = null ) { if ( null !== $ attribute ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { return $ attribute . '="' . implode ( ' ' , $ this -> attributes [ $ attribute ] ) . '"' ; } } else { $ return = array ( ) ; for...
Generate the HTML code for the attributes
59,723
public function exists ( $ attribute , $ value = null ) { $ attribute = strval ( $ attribute ) ; if ( \ Thin \ Arrays :: exists ( $ attribute , $ this -> attributes ) ) { if ( null === $ value || in_array ( strval ( $ value ) , $ this -> attributes [ $ attribute ] ) ) { return true ; } } return false ; }
Check whether a given attribute or attribute value exists
59,724
public static function getStatementType ( String $ query ) : Int { $ type = 0 ; if ( preg_match ( "/^SELECT|select|Select([^ ]+)/" , $ query ) ) { $ type = 1 ; } if ( preg_match ( "/^INSERT([^ ]+)/" , $ query ) ) { $ type = 2 ; } if ( preg_match ( "/^UPDATE([^ ]+)/" , $ query ) ) { $ type = 3 ; } if ( preg_match ( "/^D...
This method gets and returns the statement type .
59,725
public function actionPhrase ( ) { $ this -> stdout ( 'phraseLiveTime: ' . \ Yii :: $ app -> cmsSearch -> phraseLiveTime . "\n" ) ; if ( \ Yii :: $ app -> cmsSearch -> phraseLiveTime ) { $ deleted = CmsSearchPhrase :: deleteAll ( [ '<=' , 'created_at' , \ Yii :: $ app -> formatter -> asTimestamp ( time ( ) ) - ( int ) ...
Remove old searches
59,726
private function write_to ( $ file , $ data ) { $ handler = fopen ( $ file , "w" ) ; fwrite ( $ handler , $ data ) ; fclose ( $ handler ) ; }
Creates the handler and writes the files .
59,727
public function write ( $ path = '' , $ file = '' , $ content = '' ) { $ the_path = Application :: config ( ) -> public_folder ( ) . '/' . $ path ; @ mkdir ( $ the_path , 0755 , true ) ; $ this -> write_to ( $ the_path . '/' . $ file , $ content ) ; }
Write the file .
59,728
protected function _deserializeResponse ( $ responseData ) { try { $ this -> getResponseBody ( ) -> deserialize ( $ responseData ) ; } catch ( Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $ e ) { $ logMessage = sprintf ( '[%s] Error Payload Response Body: %s' , __CLASS__ , $ this -> cleanAuthXml ( $ respo...
Deserialized the response xml into response payload if an exception is thrown catch it and set the error payload and deserialized the response xml into it .
59,729
protected function _sendRequest ( ) { $ this -> _lastRequestsResponse = null ; $ httpMethod = strtolower ( $ this -> _config -> getHttpMethod ( ) ) ; if ( ! method_exists ( $ this , $ httpMethod ) ) { throw Mage :: exception ( 'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action' , sprintf ( 'HTTP action %s not su...
Send get or post CURL request to the API URI .
59,730
protected function _post ( ) { $ requestXml = $ this -> getRequestBody ( ) -> serialize ( ) ; if ( $ this -> _helperConfig -> isDebugMode ( ) ) { $ logMessage = sprintf ( '[%s] Request Body: %s' , __CLASS__ , $ this -> cleanAuthXml ( $ requestXml ) ) ; Mage :: log ( $ logMessage , Zend_Log :: DEBUG ) ; } $ xml = simple...
Send post CURL request .
59,731
protected function _get ( ) { $ this -> _lastRequestsResponse = Requests :: post ( $ this -> _config -> getEndpoint ( ) , $ this -> _buildHeader ( ) ) ; return $ this -> _lastRequestsResponse -> success ; }
Send get CURL request .
59,732
public function cleanAuthXml ( $ xml ) { $ xml = preg_replace ( '#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#' , '$1***$2' , $ xml ) ; $ xml = preg_replace ( '#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#' , '$1***$2' , $ xml ) ; $ xml = pr...
Scrub the auth request XML message of any sensitive data - CVV CC number .
59,733
public function set ( array $ methods , array $ args ) : RouterInterface { list ( $ pattern , $ callable ) = $ args ; $ route = new Route ( $ methods , $ pattern , $ callable ) ; $ this -> setRoute ( $ route ) ; return $ this ; }
Abstraction of setter
59,734
public function checkMethods ( array $ methods ) : array { return array_map ( function ( $ method ) { $ method = strtolower ( $ method ) ; if ( ! \ in_array ( $ method , self :: METHODS , false ) ) { throw new Exception ( "Method \"$method\" is not in allowed list [" . implode ( ',' , self :: METHODS ) . ']' ) ; } retu...
Check if passed methods in allowed list
59,735
public function map ( array $ methods , string $ pattern , $ callable ) : MethodsInterface { $ methods = $ this -> checkMethods ( $ methods ) ; $ this -> set ( $ methods , [ $ pattern , $ callable ] ) ; return $ this ; }
Callable must be only selected methods
59,736
public function any ( string $ pattern , $ callable ) : MethodsInterface { $ this -> set ( self :: METHODS , [ $ pattern , $ callable ] ) ; return $ this ; }
Any method should be callable
59,737
public function setRoute ( RouteInterface $ route ) : RouterInterface { $ regexp = $ route -> getRegexp ( ) ; $ this -> _routes [ $ regexp ] = $ route ; return $ this ; }
Add route into the array of routes
59,738
private function checkMatches ( string $ uri , string $ method ) : array { return array_map ( function ( $ regexp , $ route ) use ( $ uri , $ method ) { $ match = preg_match_all ( $ regexp , $ uri , $ matches ) ; if ( $ match && $ route -> checkMethod ( $ method ) ) { $ route -> setVariables ( $ matches ) ; return $ ro...
Find route object by URL nad method
59,739
private function getMatches ( ) : array { $ uri = $ this -> getRequest ( ) -> getUri ( ) -> getPath ( ) ; $ method = $ this -> getRequest ( ) -> getMethod ( ) ; $ method = strtolower ( $ method ) ; return $ this -> checkMatches ( $ uri , $ method ) ; }
Find optimal route from array of routes by regexp and uri
59,740
public function getRoute ( ) : RouteInterface { $ matches = $ this -> getMatches ( ) ; $ matches = array_values ( array_filter ( $ matches ) ) ; $ result = ! empty ( $ matches ) ? $ matches [ 0 ] : $ this -> getError ( ) ; return $ result ; }
Parse URI by Regexp from routes and return single route
59,741
public function getRoutes ( bool $ keys = false ) : array { return $ keys ? array_keys ( $ this -> _routes ) : $ this -> _routes ; }
Get all available routes
59,742
public function get ( string $ index ) : string { if ( ! $ this -> isValid ( $ index ) ) { throw new \ InvalidArgumentException ( 'The specified value does not exist' ) ; } return $ this -> map [ $ index ] ; }
Retrieve a value
59,743
public function addValue ( string $ key , string $ value ) : void { $ this -> map [ $ key ] = $ value ; }
Add a new value to the map
59,744
public function deleteValue ( string $ key ) : void { if ( isset ( $ this -> map [ $ key ] ) ) { unset ( $ this -> map [ $ key ] ) ; } }
Delete a value from the map based on the key
59,745
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ evm = $ serviceLocator -> get ( 'EventManager' ) ; $ config = $ serviceLocator -> get ( 'Config' ) ; $ config = empty ( $ config [ 'valu_so' ] ) ? [ ] : $ config [ 'valu_so' ] ; $ cacheConfig = isset ( $ config [ 'cache' ] ) ? $ config [ 'ca...
Create a ServiceBroker
59,746
public function create ( $ filename , $ content ) { $ filename = str :: path ( $ filename ) ; $ this -> createDirectory ( dirname ( $ filename ) ) ; return file_put_contents ( $ filename , $ content ) ; }
To create file
59,747
public function delete ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return @ unlink ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; }
To delete file
59,748
public function update ( $ filename , $ content ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return $ this -> create ( $ filename , $ content ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; }
To update file
59,749
public function get ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return file_get_contents ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; }
To get file content
59,750
public function append ( $ filename , $ content ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return file_put_contents ( $ filename , $ content , FILE_APPEND ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; }
To append file
59,751
public function size ( $ filename ) { if ( $ this -> exists ( $ filename ) && $ this -> isFile ( $ filename ) ) { return filesize ( $ filename ) ; } throw new FileNotFoundException ( 'File not found in the path [ ' . $ filename . ' ].' ) ; }
To get a filesize in byte
59,752
public function files ( $ directoryName ) { if ( ! $ this -> isDir ( $ directoryName ) ) { throw new FileNotFoundException ( 'Directory not found in the path [ ' . $ directoryName . ' ].' ) ; } $ files = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directoryName , RecursiveDirectoryIterator :: SKI...
To get all files in a directory
59,753
public function directories ( $ directoryName ) { if ( ! $ this -> isDir ( $ directoryName ) ) { throw new FileNotFoundException ( 'Directory not found in the path [ ' . $ directoryName . ' ].' ) ; } $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directoryName , RecursiveDirectoryIterat...
To get all directories in a directory
59,754
public function cleanDirectory ( $ directoryName , $ deleteRootDirectory = false ) { if ( is_dir ( $ directoryName ) ) { $ files = glob ( $ directoryName . '/*' , GLOB_NOSORT ) ; foreach ( $ files as $ file ) { $ this -> cleanDirectory ( $ file , true ) ; } if ( file_exists ( $ directoryName ) && ( $ deleteRootDirector...
To clean a directory
59,755
public function addElement ( $ tag , array $ attributes = [ ] ) { if ( $ tag instanceof self ) { $ htmlTag = $ tag ; $ htmlTag -> top = $ this -> top ; $ htmlTag -> attrs ( $ attributes ) ; $ this -> elements -> add ( $ htmlTag ) ; return $ htmlTag ; } return self :: make ( $ tag , $ attributes , $ this -> hasParent ( ...
Add element at an existing Markup
59,756
public function getFirst ( ) { $ element = null ; if ( $ this -> hasParent ( ) and $ this -> parent -> hasElements ( ) ) { $ element = $ this -> parent -> elements [ 0 ] ; } return $ element ; }
Return first child of parent of current object
59,757
protected function getMountPoint ( $ path ) { while ( $ path !== '' ) { if ( isset ( $ this -> filesystems [ $ path ] ) ) { return $ path ; } $ path = substr ( $ path , 0 , strrpos ( $ path , '/' ) ) ; } return '/' ; }
Find mount point of the path
59,758
public static function make ( $ value , $ rounds = 8 ) { $ work = str_pad ( $ rounds , 2 , '0' , STR_PAD_LEFT ) ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ salt = openssl_random_pseudo_bytes ( 16 ) ; } else { $ salt = Inflector :: random ( 40 ) ; } $ salt = substr ( strtr ( base64_encode ( $ salt ) ,...
Hash a password using the Bcrypt hashing scheme .
59,759
public static function registerSystemErrors ( Slim $ app ) : void { $ c = $ app -> getContainer ( ) ; $ c [ 'errorHandler' ] = function ( $ c ) { return function ( Request $ request , Response $ response , \ Exception $ exception ) use ( $ c ) : Response { $ response = $ c [ 'response' ] ; return $ response -> withStat...
Injects a custom error handling into the Slim - framework
59,760
public static function make ( TagInterface $ tag ) { if ( $ tag -> getType ( ) === '' and $ tag -> getText ( ) !== '' ) { return $ tag -> getText ( ) ; } return self :: isAutoClosed ( $ tag -> getType ( ) ) ? self :: open ( $ tag , true ) : self :: open ( $ tag ) . $ tag -> getText ( ) . $ tag -> renderElements ( ) . s...
Render a Tag and its elements
59,761
private static function open ( TagInterface $ tag , $ autoClosed = false ) { $ output = '<' . $ tag -> getType ( ) ; if ( $ tag -> hasAttributes ( ) ) { $ output .= ' ' . $ tag -> renderAttributes ( ) ; } $ output .= ( $ autoClosed ? '/>' : '>' ) ; return $ output ; }
Render open Tag
59,762
public function bindParam ( $ placeholder , & $ var , $ type = null ) { $ this -> param_list [ $ placeholder ] = & $ var ; if ( ! empty ( $ type ) && in_array ( $ type , $ this -> _type_list ) ) { $ this -> type_list [ $ placeholder ] = & $ type ; } return true ; }
binds a parameter
59,763
public function fetchAll ( $ type = null ) { try { if ( $ this -> res === false ) { throw new DatabaseException ( __METHOD__ . " No ressource has been given" , MySQL :: NO_RESSOURCE , MySQL :: SEVERITY_DEBUG , __FILE__ , __LINE__ ) ; } switch ( $ type ) { case MySQL :: FETCH_ASSOC : return $ this -> _db -> fetch_assoc_...
fetch all option
59,764
public function hasTag ( $ tag ) { foreach ( $ this -> lines as $ line ) { if ( strpos ( $ line , '@' . $ tag ) === 0 ) { return TRUE ; } } return FALSE ; }
Check if a tag is set in the comment
59,765
public function getTags ( $ tag ) { $ tags = array ( ) ; foreach ( $ this -> lines as $ line ) { if ( strpos ( $ line , '@' . $ tag ) === 0 ) { $ tags [ ] = trim ( substr ( $ line , strlen ( '@' . $ tag ) ) ) ; } } return $ tags ; }
Return array of matching tags
59,766
public function getLongDescription ( ) { $ comment = '' ; foreach ( $ this -> lines as $ key => $ line ) { if ( $ key == 0 || ( $ line && $ line [ 0 ] == '@' ) ) { continue ; } if ( $ comment ) { $ comment .= "\n" ; } $ comment .= $ line ; } return $ comment ; }
Return long description This is every other line of a comment besides the first line and any tags
59,767
public static function starComment ( $ strComment , $ intTabs = 0 ) { $ strReturn = '' ; $ arrComment = explode ( "\n" , $ strComment ) ; $ intFirstSlash = strpos ( $ arrComment [ 0 ] , '/' ) ; $ strPrefix = ( $ intFirstSlash ) ? substr ( $ arrComment [ 0 ] , 0 , $ intFirstSlash ) : NULL ; $ strComment = self :: cleanC...
Return a stared comment
59,768
public static function lineComment ( $ strComment , $ intTabs = 0 ) { $ strReturn = '' ; $ arrComment = explode ( "\n" , $ strComment ) ; $ intFirstSlash = strpos ( $ arrComment [ 0 ] , '/' ) ; $ strPrefix = ( $ intFirstSlash ) ? substr ( $ arrComment [ 0 ] , 0 , $ intFirstSlash ) : NULL ; $ strComment = self :: cleanC...
Return a lined comment
59,769
public function getCommits ( ) { $ log = $ this -> execute ( "git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' " . $ this -> repository_path ) ; $ this -> repository_type = 'git' ; return $ this -> parseLog ( $ log ) ; }
Get the list of Git commits for the repository as a structured array
59,770
public function set ( $ key , $ value ) { $ this -> values [ $ this -> normalizeKey ( $ key ) ] = $ value ; return $ this ; }
Set data key to value
59,771
public function get ( $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) { $ isInvokable = is_object ( $ this -> values [ $ this -> normalizeKey ( $ key ) ] ) && method_exists ( $ this -> values [ $ this -> normalizeKey ( $ key ) ] , '__invoke' ) ; return $ isInvokable ? $ this -> values [ $ this -> normalizeK...
Get values value with key
59,772
function identity ( ) { if ( ! $ this -> identity ) $ this -> identity = new BaseIdentity ( get_class ( $ this ) ) ; return $ this -> identity ; }
Get Authorized User Identity
59,773
public function set ( $ name , $ value , $ scope = null ) { if ( strpos ( $ name , ':' ) ) { list ( $ entry , $ name ) = explode ( ':' , $ name ) ; $ cfg = $ this -> getConfig ( $ entry , array ( ) , $ scope ) ; $ cfg [ $ name ] = $ value ; return $ this -> setConfig ( $ entry , $ cfg , $ scope ) ; } else { return $ th...
Set the value of a specific option with depth
59,774
public function setConfigs ( array $ options , $ scope = null ) { if ( ! is_null ( $ scope ) ) { $ this -> registry [ $ scope ] = $ options ; } else { $ this -> registry = $ options ; } return $ this ; }
Set an array of options
59,775
public function addConfig ( $ name , $ value , $ scope = null ) { return $ this -> setConfig ( $ name , $ value , $ scope ) ; }
Alias of the setConfig method
59,776
static function bytes ( $ bytes = Constants :: BYTES ) { Helpers :: rangeCheck ( $ bytes , Constants :: BYTES_MAX , Constants :: BYTES_MIN , 'Entropy' , 'bytes' ) ; return \ Sodium \ randombytes_buf ( $ bytes ) ; }
Returns a string of random bytes to the client .
59,777
static function integer ( $ range = Constants :: RANGE ) { Helpers :: rangeCheck ( $ range , Constants :: RANGE_MAX , Constants :: RANGE_MIN , 'Entropy' , 'integer' ) ; return \ Sodium \ randombytes_uniform ( $ range ) + 1 ; }
Returns a random integer to the client .
59,778
public function index ( ) { $ argv = \ Console_Getopt :: readPHPArgv ( ) ; $ opts = \ Console_Getopt :: getopt ( array_slice ( $ argv , 2 , count ( $ argv ) - 2 ) , 'h::p::d::r::' , null , true ) ; if ( ! empty ( $ opts [ 0 ] ) && is_array ( $ opts [ 0 ] ) ) { foreach ( $ opts [ 0 ] as $ val ) { if ( ! empty ( $ val [ ...
Runs PHP built - in web server
59,779
public static function decompress ( $ compressedFile , $ destinationFolder , $ originalFilename = null , $ format = 'gz' , $ allowedExtensions = [ 'csv' , 'tsv' ] ) { $ supported_formats = [ 'gz' , 'zip' , 'tar' ] ; if ( ! in_array ( $ format , $ supported_formats ) ) { throw new \ Exception ( 'Unsupported compression ...
decompress a file archive
59,780
public function getConfig ( $ configKey = null ) { $ default = clone $ this -> config -> configs -> default ; if ( null !== $ configKey ) { $ default -> merge ( clone $ this -> config -> configs -> { $ configKey } ) ; } return $ default -> toArray ( ) ; }
Get the default config merged with an option overriding config .
59,781
private function findRootPages ( ) : array { $ result = [ 'source' => null , 'target' => null , 'main' => null , ] ; $ this -> logger -> debug ( 'Searching root pages for source "{source}" and target "{target}"' , [ 'source' => $ this -> sourceLanguage , 'target' => $ this -> targetLanguage ] ) ; foreach ( $ this -> da...
Determine the root pages .
59,782
private function buildPageMap ( int $ mainRoot , int $ otherRoot , array & $ map , array & $ inverse ) : array { $ map [ $ otherRoot ] = $ mainRoot ; $ inverse [ $ mainRoot ] = $ otherRoot ; $ isMain = $ mainRoot === $ otherRoot ; $ lookupQueue = [ $ otherRoot ] ; do { $ children = $ this -> database -> getPagesByPidLi...
Build a map for a language and returns the map from source to main .
59,783
private function determineMapFor ( int $ index , int $ parentId , array $ inverseList ) : ? int { if ( ! isset ( $ inverseList [ $ parentId ] ) ) { throw new \ InvalidArgumentException ( 'Page id ' . $ parentId . ' has not been mapped' ) ; } $ mainSiblings = $ this -> database -> getPagesByPidList ( [ $ inverseList [ $...
Determine the mapping for the passed index .
59,784
public function getCommandToExecute ( ) { $ command = implode ( " " , array ( $ this -> bin , $ this -> script , $ this -> command , ) ) ; return trim ( preg_replace ( '/\s+/' , ' ' , $ command ) ) ; }
Returns the executable command for the task instance
59,785
public function preView ( $ output ) { $ purifierConfig = \ HTMLPurifier_Config :: createDefault ( ) ; $ purifierConfig -> set ( 'Core.Encoding' , 'UTF-8' ) ; $ purifierConfig -> set ( 'HTML.TidyLevel' , 'medium' ) ; $ purifier = new \ HTMLPurifier ( $ purifierConfig ) ; $ output = $ purifier -> purify ( $ output ) ; r...
Callback method to sanitize HTML output
59,786
public function login ( ) { $ result = $ this -> adapter -> getResult ( ) ; if ( $ result === self :: PHAVOUR_AUTH_SERVICE_SUCCESS ) { $ auth = Auth :: getInstance ( ) ; $ auth -> login ( $ this -> adapter -> getIdentity ( ) ) ; $ auth -> setRoles ( $ this -> adapter -> getRoles ( ) ) ; return true ; } elseif ( $ resul...
Log a user in using the given adapter from the construct
59,787
public function build ( ) { $ options_data = $ this -> buildOptionsData ( ) ; $ out_text = $ this -> buildUsageLine ( $ this -> arguments_spec -> getUsage ( ) , $ options_data ) ; $ options_text = '' ; if ( $ options_data [ 'lines' ] ) { foreach ( $ options_data [ 'lines' ] as $ option_line_data ) { $ options_text .= $...
Builds nicely formatted help text
59,788
protected function buildUsageLine ( $ usage_data , $ options_data ) { if ( $ usage_data [ 'use_argv_self' ] ) { $ self_name = $ _SERVER [ 'argv' ] [ 0 ] ; } else { $ self_name = $ usage_data [ 'self' ] ; } $ has_options = ( count ( $ options_data [ 'lines' ] ) > 0 ? true : false ) ; $ has_named_args = ( count ( $ usage...
builds the usage line
59,789
protected function buildOptionLine ( $ option_line_data , $ options_data ) { $ padding = $ options_data [ 'padding' ] ; $ required = $ option_line_data [ 'spec' ] [ 'required' ] ; $ out = str_pad ( $ option_line_data [ 'switch_text' ] , $ padding ) ; $ out .= ( strlen ( $ option_line_data [ 'spec' ] [ 'help' ] ) ? ' ' ...
builds an option line
59,790
protected function generateValueNamesHelp ( $ named_args_spec ) { $ first = true ; $ out = '' ; foreach ( $ named_args_spec as $ named_arg_spec ) { $ out .= ( $ first ? '' : ' ' ) ; if ( $ named_arg_spec [ 'required' ] ) { $ out .= ConsoleFormat :: applyformatToText ( 'bold' , 'yellow' , '<' . $ named_arg_spec [ 'name'...
gerenates the value names in the usage line
59,791
protected function buildOptionsData ( ) { $ options_data = array ( 'lines' => array ( ) , 'padding' => 0 , ) ; foreach ( $ this -> arguments_spec as $ option_line_spec ) { $ options_data [ 'lines' ] [ ] = $ this -> buildOptionLineData ( $ option_line_spec ) ; } $ options_data [ 'padding' ] = $ this -> buildSwitchTextPa...
builds options data from the arguments spec
59,792
protected function buildOptionLineData ( $ option_line_spec ) { $ data = array ( ) ; $ switch_text = '' ; if ( strlen ( $ option_line_spec [ 'short' ] ) ) { $ switch_text .= "-" . $ option_line_spec [ 'short' ] ; } if ( strlen ( $ option_line_spec [ 'long' ] ) ) { $ switch_text .= ( $ switch_text ? ", " : "" ) . "--" ....
builds a line of options data from a line of the argument spec
59,793
protected function buildSwitchTextPaddingLength ( $ options_data ) { $ padding_len = 0 ; foreach ( $ options_data [ 'lines' ] as $ option_line_data ) { $ padding_len = max ( $ padding_len , strlen ( $ option_line_data [ 'switch_text' ] ) ) ; } return $ padding_len ; }
calculates the maximum padding for all options
59,794
public function addObjects ( SplObjectStorage $ models ) { foreach ( $ models as $ model ) { $ this -> add ( $ model ) ; } return $ this ; }
Link all models from the SplObjectStorage
59,795
public function addAll ( Models $ other ) { if ( $ other -> count ( ) > 0 ) { $ this -> models -> addAll ( $ other -> models ) ; } return $ this ; }
Add all models from a different Models collection
59,796
public function sort ( Closure $ closure ) { $ sorted = clone $ this ; $ sorted -> models = Objects :: sort ( $ sorted -> models , $ closure ) ; return $ sorted ; }
Sort the models collection using a comparation closure
59,797
public function byRepo ( Closure $ yield ) { $ repos = Objects :: groupBy ( $ this -> models , function ( AbstractModel $ model ) { return $ model -> getRepo ( ) -> getRootRepo ( ) ; } ) ; foreach ( $ repos as $ repo ) { $ models = new Models ( ) ; $ models -> addObjects ( $ repos -> getInfo ( ) ) ; $ yield ( $ repo , ...
Group models by repo call yield for each repo
59,798
public function pluckProperty ( $ property ) { $ values = [ ] ; foreach ( $ this -> models as $ model ) { $ values [ ] = $ model -> $ property ; } return $ values ; }
Return the value of a property for each model
59,799
public function isEmptyProperty ( $ property ) { foreach ( $ this -> models as $ model ) { if ( $ model -> $ property ) { return false ; } } return true ; }
Return false if there is at least one non - empty property of a model .