idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
27,200 | public function reset ( int $ scanHeight = null ) : JsonResponse { $ params = [ ] ; if ( ! is_null ( $ scanHeight ) ) $ params [ 'scanHeight' ] = $ scanHeight ; return $ this -> rpcPost ( 'reset' , $ params ) ; } | Re - syncs the wallet . |
27,201 | public function createAddress ( string $ secretSpendKey = null , string $ publicSpendKey = null ) : JsonResponse { $ params = [ ] ; if ( ! is_null ( $ secretSpendKey ) ) $ params [ 'secretSpendKey' ] = $ secretSpendKey ; if ( ! is_null ( $ publicSpendKey ) ) $ params [ 'publicSpendKey' ] = $ publicSpendKey ; return $ this -> rpcPost ( 'createAddress' , $ params ) ; } | Creates an additional address in your wallet . |
27,202 | public function getBalance ( string $ address = null ) : JsonResponse { $ params = [ ] ; if ( ! is_null ( $ address ) ) $ params [ 'address' ] = $ address ; return $ this -> rpcPost ( 'getBalance' , $ params ) ; } | Method returns a balance for a specified address . |
27,203 | public function getBlockHashes ( int $ firstBlockIndex , int $ blockCount ) : JsonResponse { $ params = [ 'firstBlockIndex' => $ firstBlockIndex , 'blockCount' => $ blockCount , ] ; return $ this -> rpcPost ( 'getBlockHashes' , $ params ) ; } | Returns an array of block hashes for a specified block range . |
27,204 | public function getTransactionHashes ( int $ blockCount , int $ firstBlockIndex = null , string $ blockHash = null , array $ addresses = null , string $ paymentId = null ) : JsonResponse { $ params = [ 'blockCount' => $ blockCount , ] ; if ( ! is_null ( $ firstBlockIndex ) ) $ params [ 'firstBlockIndex' ] = $ firstBlockIndex ; if ( ! is_null ( $ blockHash ) ) $ params [ 'blockHash' ] = $ blockHash ; if ( ! is_null ( $ addresses ) ) $ params [ 'addresses' ] = $ addresses ; if ( ! is_null ( $ paymentId ) ) $ params [ 'paymentId' ] = $ paymentId ; return $ this -> rpcPost ( 'getTransactionHashes' , $ params ) ; } | Returns an array of block and transaction hashes . Transaction consists of transfers . Transfer is an amount - address pair . There could be several transfers in a single transaction . |
27,205 | public function getUnconfirmedTransactionHashes ( array $ addresses = null ) : JsonResponse { $ params = [ ] ; if ( ! is_null ( $ addresses ) ) $ params [ 'addresses' ] = $ addresses ; return $ this -> rpcPost ( 'getUnconfirmedTransactionHashes' , $ params ) ; } | Returns information about the current unconfirmed transaction pool or for a specified addresses . Transaction consists of transfers . Transfer is an amount - address pair . There could be several transfers in a single transaction . |
27,206 | public function sendTransaction ( int $ anonymity , array $ transfers , int $ fee , array $ addresses = null , int $ unlockTime = null , string $ extra = null , string $ paymentId = null , string $ changeAddress = null ) : JsonResponse { $ params = [ 'anonymity' => $ anonymity , 'transfers' => $ transfers , 'fee' => $ fee , ] ; if ( ! is_null ( $ addresses ) ) $ params [ 'addresses' ] = $ addresses ; if ( ! is_null ( $ unlockTime ) ) $ params [ 'unlockTime' ] = $ unlockTime ; if ( ! is_null ( $ extra ) ) $ params [ 'extra' ] = $ extra ; if ( ! is_null ( $ paymentId ) ) $ params [ 'paymentId' ] = $ paymentId ; if ( ! is_null ( $ changeAddress ) ) $ params [ 'changeAddress' ] = $ changeAddress ; return $ this -> rpcPost ( 'sendTransaction' , $ params ) ; } | Allows you to send transaction to one or several addresses . Also it allows you to use a payment_id for a transaction to a single address . |
27,207 | public function sendFusionTransaction ( int $ threshold , int $ anonymity , array $ addresses = null , string $ destinationAddress = null ) : JsonResponse { $ params = [ 'threshold' => $ threshold , 'anonymity' => $ anonymity , ] ; if ( ! is_null ( $ addresses ) ) $ params [ 'addresses' ] = $ addresses ; if ( ! is_null ( $ destinationAddress ) ) $ params [ 'destinationAddress' ] = $ destinationAddress ; return $ this -> rpcPost ( 'sendFusionTransaction' , $ params ) ; } | Allows you to send a fusion transaction by taking funds from selected addresses and transferring them to the destination address . |
27,208 | public function estimateFusion ( int $ threshold , array $ addresses = null ) : JsonResponse { $ params = [ 'threshold' => $ threshold , ] ; if ( ! is_null ( $ addresses ) ) $ params [ 'addresses' ] = $ addresses ; return $ this -> rpcPost ( 'sendFusionTransaction' , $ params ) ; } | Counts the number of unspent outputs of the specified addresses and returns how many of those outputs can be optimized . This method is used to understand if a fusion transaction can be created . If fusionReadyCount returns a value = 0 then a fusion transaction cannot be created . |
27,209 | public function createIntegratedAddress ( string $ address , string $ paymentId ) : JsonResponse { $ params = [ 'address' => $ address , 'paymentId' => $ paymentId , ] ; return $ this -> rpcPost ( 'createIntegratedAddress' , $ params ) ; } | Combines an address and a paymentId into an integrated address which contains both in an encoded form . This allows users to not have to supply a payment Id in their transfer and hence cannot forget it . |
27,210 | public function getPageNumbers ( array $ pages , $ current ) { $ offset = $ current * $ this -> step ; return array_slice ( $ pages , $ offset , $ this -> step ) ; } | Filter page numbers via current style adapter |
27,211 | protected function isVersionNumeric ( $ version ) { foreach ( explode ( '.' , $ version ) as $ part ) { if ( ! is_numeric ( $ part ) ) { return false ; } } return true ; } | Compute if version is numeric . |
27,212 | protected function incrementVersion ( $ version , $ patch_limit = 20 , $ minor_limit = 50 ) { if ( ! $ this -> isVersionNumeric ( $ version ) ) { throw new DeploymentRuntimeException ( 'Unable to increment semantic version.' ) ; } list ( $ major , $ minor , $ patch ) = explode ( '.' , $ version ) ; if ( $ patch < $ patch_limit ) { ++ $ patch ; } else if ( $ minor < $ minor_limit ) { ++ $ minor ; $ patch = 0 ; } else { ++ $ major ; $ patch = 0 ; $ minor = 0 ; } return "{$major}.{$minor}.{$patch}" ; } | Increment the semantic version number . |
27,213 | private function getUploader ( ) { if ( is_null ( $ this -> uploader ) ) { $ this -> uploader = UploaderFactory :: build ( $ this -> rootDir . $ this -> path , $ this -> plugins ) ; } return $ this -> uploader ; } | Returns prepared upload chain |
27,214 | private function getFileHandler ( ) { if ( is_null ( $ this -> fileHandler ) ) { $ path = rtrim ( $ this -> path , '/' ) ; $ this -> fileHandler = new FileHandler ( $ this -> rootDir . $ path ) ; } return $ this -> fileHandler ; } | Returns prepared FileHandler instance |
27,215 | public function getImageBag ( ) { if ( $ this -> imageBag == null ) { $ this -> imageBag = new ImageBag ( new LocationBuilder ( $ this -> rootDir , $ this -> rootUrl , $ this -> path ) ) ; } return $ this -> imageBag ; } | Returns prepared ImageBag instance |
27,216 | public function merge ( $ masterPk , $ alias , array $ rows , $ junction , $ column , $ table , $ pk , $ columns ) { foreach ( $ rows as & $ row ) { $ value = $ row [ $ masterPk ] ; $ row [ $ alias ] = $ this -> getSlaveData ( $ table , $ pk , $ junction , $ column , $ value , $ columns ) ; } return $ rows ; } | Merges as many - to - many |
27,217 | private function getSlaveData ( $ slaveTable , $ slavePk , $ junction , $ column , $ value , $ columns ) { $ ids = $ this -> queryJunctionTable ( $ junction , $ column , $ value , '*' ) ; if ( empty ( $ ids ) ) { return array ( ) ; } else { return $ this -> queryTable ( $ slaveTable , $ slavePk , $ ids , $ columns ) ; } } | Returns slave data from associated table |
27,218 | private function leaveOnlyCurrent ( array $ row , $ target ) { $ result = array ( ) ; foreach ( $ row as $ column => $ value ) { if ( $ column != $ target ) { $ result [ $ column ] = $ value ; } } return $ result ; } | Removes all columns leaving only target one |
27,219 | private function queryJunctionTable ( $ table , $ column , $ value , $ columns ) { $ rows = $ this -> queryTable ( $ table , $ column , array ( $ value ) , $ columns ) ; foreach ( $ rows as & $ row ) { $ row = $ this -> leaveOnlyCurrent ( $ row , $ column ) ; } return $ this -> extractValues ( $ rows ) ; } | Queries junction table |
27,220 | private function createPdo ( $ vendor , array $ options ) { if ( isset ( $ this -> map [ $ vendor ] ) ) { $ connector = $ this -> map [ $ vendor ] ; $ driver = new $ connector ( ) ; $ builder = new InstanceBuilder ( ) ; return $ builder -> build ( '\Krystal\Db\Sql\LazyPDO' , $ driver -> getArgs ( $ options ) ) ; } else { throw new RuntimeException ( sprintf ( 'Unknown database vendor name supplied "%s"' , $ vendor ) ) ; } } | Returns PDO instance |
27,221 | public function build ( $ vendor , array $ options ) { return new Db ( new QueryBuilder ( ) , $ this -> createPdo ( $ vendor , $ options ) , $ this -> paginator , new QueryLogger ( ) ) ; } | Builds database service instance |
27,222 | public function transition ( $ event ) : void { $ this -> apply ( $ event , self :: HANDLE_PREFIX ) ; $ this -> version ++ ; } | Transition saga to new state |
27,223 | protected static function getOption ( $ optionName , $ castToInt = true ) { $ optionValue = isset ( self :: $ options [ $ optionName ] ) ? self :: $ options [ $ optionName ] : get_option ( $ optionName ) ; return $ castToInt === true ? ( int ) $ optionValue : $ optionValue ; } | Get the specified option . |
27,224 | protected function hasGitBranch ( $ branch_name ) { $ task = $ this -> getGitBuildStack ( ) -> exec ( "rev-parse -q --verify {$branch_name}" ) ; $ result = $ this -> runSilentCommand ( $ task ) ; return ! empty ( $ result -> getMessage ( ) ) ; } | Has git branch . |
27,225 | protected function hasGitTrackedFilesChanged ( ) { $ task = $ this -> getGitBuildStack ( ) -> exec ( "status --untracked-files=no --porcelain" ) ; $ result = $ this -> runSilentCommand ( $ task ) ; $ changes = array_filter ( explode ( "\n" , $ result -> getMessage ( ) ) ) ; return ( bool ) count ( $ changes ) != 0 ; } | Has git tracked files changed . |
27,226 | protected function askBuildVersion ( ) { $ last_version = $ this -> gitLatestVersionTag ( ) ; $ next_version = $ this -> incrementVersion ( $ last_version ) ; $ question = ( new Question ( "Set build version [{$next_version}]: " , $ next_version ) ) -> setValidator ( function ( $ input_version ) use ( $ last_version ) { $ input_version = trim ( $ input_version ) ; if ( version_compare ( $ input_version , $ last_version , '==' ) ) { throw new \ RuntimeException ( 'Build version has already been used.' ) ; } if ( ! $ this -> isVersionNumeric ( $ input_version ) ) { throw new \ RuntimeException ( 'Build version is not numeric.' ) ; } return $ input_version ; } ) ; return $ this -> doAsk ( $ question ) ; } | Ask build version . |
27,227 | protected function runGitInitAdd ( ) { $ repo = $ this -> gitRepo ( ) ; $ origin = $ this -> gitOrigin ( ) ; $ branch = $ this -> gitBranch ( ) ; $ stack = $ this -> getGitBuildStack ( ) ; if ( ! $ this -> buildHasGit ( ) ) { $ stack -> exec ( 'init' ) -> exec ( "remote add {$origin} {$repo}" ) ; if ( $ this -> gitRemoteBranchExist ( ) ) { $ stack -> exec ( 'fetch --all' ) -> exec ( "reset --soft {$origin}/{$branch}" ) ; } } else { $ stack -> checkout ( $ branch ) -> pull ( $ origin , $ branch ) ; } $ result = $ stack -> add ( '.' ) -> run ( ) ; $ this -> validateTaskResult ( $ result ) ; return $ this ; } | Run git initialize add . |
27,228 | protected function gitRemoteBranchExist ( ) { $ task = $ this -> getGitBuildStack ( ) -> exec ( "ls-remote --exit-code --heads {$this->gitRepo()} {$this->gitBranch()}" ) ; $ result = $ this -> runSilentCommand ( $ task ) ; return $ result -> getExitCode ( ) === 0 ; } | Deployment git remote branch exist . |
27,229 | protected function gitRepo ( $ throw_exception = true ) { $ options = $ this -> getOptions ( ) ; $ repo = isset ( $ options [ 'repo_url' ] ) ? $ options [ 'repo_url' ] : null ; if ( ! isset ( $ repo ) && $ throw_exception ) { throw new DeploymentRuntimeException ( 'Missing Git repository in deploy options.' ) ; } return $ repo ; } | Deployment git build repo . |
27,230 | protected function verifySelectQuery ( SelectQuery $ query ) { $ this -> verifyScope ( $ query ) ; $ this -> verifyRequiredFields ( $ query ) ; $ this -> verifyFields ( $ query ) ; $ this -> verifyLimits ( $ query ) ; } | Verifica la validez del query a ejecutar |
27,231 | protected function verifyRequiredFields ( SelectQuery $ query , array $ requiredFields = null ) { if ( $ requiredFields == null ) { $ requiredFields = $ this -> getRequiredFields ( ) ; } if ( ! empty ( $ requiredFields ) ) { foreach ( $ requiredFields as $ requiredField ) { if ( empty ( $ query -> getWhereCondition ( $ requiredField , null , false , true ) ) ) { throw new RuntimeException ( "Condition required: $requiredField" ) ; } } } } | Valida que el query contenga los campos requeridos |
27,232 | protected function verifyFields ( SelectQuery $ query ) { $ foundField = null ; if ( $ this -> hasOtherFields ( $ query , null , false , $ foundField ) ) { throw new RuntimeException ( "Invalid fields on query : $foundField" ) ; } } | Valida que el query no invoque campos no definidos en el recurso y no tenga joins |
27,233 | protected function verifyLimits ( SelectQuery $ query ) { if ( empty ( $ query -> getLimit ( ) ) ) { $ query -> limit ( $ this -> getDefaultLimit ( ) ) ; } else if ( $ query -> getLimit ( ) > $ this -> getMaxLimit ( ) ) { $ query -> limit ( $ this -> getMaxLimit ( ) ) ; } } | Verifica que se hayan establecido los limites de la consulta |
27,234 | private function renameSource ( Query $ query , string $ tableName = null ) : string { if ( $ tableName == null ) { $ tableName = $ this -> getTableName ( ) ; } $ previusSource = $ query -> getTable ( ) ; if ( ! empty ( $ tableName ) ) { $ query -> table ( $ tableName ) ; } return $ previusSource ; } | Renombra la fuente de datos por el nombre de la tabla indicada |
27,235 | private function renameConditionFields ( ConditionGroup $ conditionGroup , $ namesMap = null , $ originalSource = null , $ newSource = null ) { if ( ! $ conditionGroup -> isEmpty ( ) ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ conditions = & $ conditionGroup -> getConditions ( ) ; foreach ( $ conditions as $ key => & $ condition ) { switch ( $ condition -> type ) { case ConditionType :: GROUP : $ this -> renameConditionFields ( $ condition -> group , $ namesMap , $ originalSource , $ newSource ) ; break ; case ConditionType :: BASIC : $ newName = $ this -> getFieldNewName ( $ condition -> field , $ namesMap , $ originalSource , $ newSource ) ; if ( $ newName != null ) { $ condition -> field = $ newName ; } if ( $ condition -> operator == ConditionOperator :: EQUALS_FIELD ) { $ newName = $ this -> getFieldNewName ( $ condition -> value , $ namesMap , $ originalSource , $ newSource ) ; if ( $ newName != null ) { $ condition -> value = $ newName ; } } break ; case ConditionType :: RAW : foreach ( $ namesMap as $ fieldName => $ dbName ) { $ condition -> sql = preg_replace ( '/\b' . $ fieldName . '(?=$|\s)/' , $ dbName , $ condition -> sql ) ; $ condition -> sql = preg_replace ( '/\b' . $ originalSource . $ fieldName . '(?=$|\s)/' , "$newSource.$dbName" , $ condition -> sql ) ; } break ; } } } } | Renombra los campos involucrados en condiciones where segun el mapa indicado |
27,236 | private function renameSetFields ( Query $ query , $ columnNames , $ originalSource , $ newSource ) { $ renamedFields = [ ] ; foreach ( $ query -> getFields ( ) as $ field => $ value ) { $ newName = $ this -> getFieldNewName ( $ field , $ columnNames , $ originalSource , $ newSource ) ; if ( $ newName != null ) { $ renamedFields [ $ newName ] = $ value ; } } $ query -> fields ( $ renamedFields ) ; } | Renombra los campos set de la sentencia update |
27,237 | protected function fieldInList ( $ field , array $ list ) : bool { $ result = in_array ( $ field , $ list ) ; if ( ! $ result && ! $ this -> isFieldCaseSensitive ( ) ) { $ result = in_array ( strtolower ( $ field ) , $ list ) ; } return $ result ; } | Indica si el field indicado se encuentra en la lista indicada como segundo argumento considerando que se indique caseSensitive en false |
27,238 | private function fieldInMap ( $ field , array $ map ) { $ result = null ; if ( array_key_exists ( $ field , $ map ) ) { $ result = $ map [ $ field ] ; } else if ( ! $ this -> isFieldCaseSensitive ( ) ) { $ field = strtolower ( $ field ) ; if ( array_key_exists ( $ field , $ map ) ) { $ result = $ map [ $ field ] ; } } return $ result ; } | Retorna el valor correspondiente al field indicado segun el map indicado como segundo argumento considerando que se indique caseSensitive en false |
27,239 | private function getFieldNewName ( $ field , $ namesMap = null , $ originalSource = null , $ newSource = null ) { $ newName = null ; if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ newName = $ this -> fieldInMap ( $ field , $ namesMap ) ; if ( empty ( $ newName ) && $ this -> fieldInList ( $ field , $ namesMap ) ) { $ newName = $ field ; } if ( empty ( $ newName ) ) { $ fieldPos = strpos ( $ field , "$originalSource." ) ; if ( $ fieldPos === 0 ) { $ searchField = substr ( $ field , strlen ( $ originalSource ) + 1 ) ; $ newName = $ this -> fieldInMap ( $ searchField , $ namesMap ) ; if ( ! empty ( $ newName ) && ! empty ( $ newSource ) && strpos ( $ newName , '.' ) === false ) { $ newName = "$newSource.$newName" ; } } } if ( empty ( $ newName ) ) { if ( preg_match ( "/\w+\s*\(\s*(\w+)\s*\)/" , $ field , $ matches ) ) { $ newName = str_replace ( $ matches [ 1 ] , $ this -> getFieldNewName ( $ matches [ 1 ] ) , $ matches [ 0 ] ) ; } } return empty ( $ newName ) ? null : $ newName ; } | Busca el posible remplazo de nombre |
27,240 | private function renameSelectFields ( SelectQuery $ query , $ namesMap = null , $ originalSource = null ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ selectFields = & $ query -> getSelectFields ( ) ; if ( empty ( $ selectFields ) ) { foreach ( $ namesMap as $ aliasName => $ columnName ) { if ( is_numeric ( $ aliasName ) ) { $ selectItem = $ columnName ; } else if ( empty ( $ columnName ) || $ aliasName === $ columnName ) { $ selectItem = $ aliasName ; } else { $ selectItem = [ $ columnName , $ aliasName ] ; } $ query -> select ( $ selectItem ) ; } } else { $ newSelectFields = [ ] ; foreach ( $ selectFields as $ selectField ) { $ aliasName = $ selectField instanceof stdClass ? trim ( $ selectField -> expression ) : trim ( $ selectField ) ; if ( $ aliasName == '*' ) { foreach ( $ namesMap as $ aliasName => $ columnName ) { if ( is_numeric ( $ aliasName ) ) { $ newSelectFields [ $ columnName ] = $ columnName ; } else { $ newSelectFields [ $ aliasName ] = $ aliasName ; } } continue ; } else if ( ! empty ( $ originalSource ) && $ aliasName == "$originalSource.*" ) { foreach ( $ namesMap as $ aliasName => $ columnName ) { if ( is_numeric ( $ aliasName ) ) { $ newSelectFields [ "$originalSource.$columnName" ] = "$originalSource.$columnName" ; } else { $ newSelectFields [ "$originalSource.$aliasName" ] = "$originalSource.$aliasName" ; } } continue ; } else { $ newSelectFields [ $ aliasName ] = $ selectField ; } } if ( ! empty ( $ newSelectFields ) ) { $ query -> selectFields ( array_values ( $ newSelectFields ) ) ; } foreach ( $ selectFields as & $ field ) { if ( $ field instanceof stdClass ) { $ aliasName = $ field -> alias ; $ columnName = $ this -> getFieldNewName ( $ field -> expression , $ namesMap , $ originalSource , $ query -> getTable ( ) ) ; } else { $ aliasName = $ field ; $ columnName = $ this -> getFieldNewName ( $ field , $ namesMap , $ originalSource , $ query -> getTable ( ) ) ; } if ( $ columnName != null ) { if ( $ columnName == $ aliasName ) { $ field = $ columnName ; } else { $ field = new stdClass ( ) ; $ field -> expression = $ columnName ; $ field -> alias = $ aliasName ; } } } } } | Modifica el select con los alias correspondientes |
27,241 | private function renameOrderByFields ( SelectQuery $ query , $ namesMap = null , $ originalSource = null ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ orderByFields = & $ query -> getOrderByFields ( ) ; if ( ! empty ( $ orderByFields ) ) { foreach ( $ orderByFields as & $ orderByField ) { $ newName = $ this -> getFieldNewName ( $ orderByField -> field , $ namesMap , $ originalSource , $ query -> getTable ( ) ) ; if ( $ newName != null ) { $ orderByField -> field = $ newName ; } } } } | Renombra los campos involucrados en ordenamiento segun el mapa indicado |
27,242 | private function renameGroupByFields ( SelectQuery $ query , $ namesMap = null , $ originalSource = null ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ groupByFields = & $ query -> getGroupByFields ( ) ; if ( ! empty ( $ groupByFields ) ) { $ source = $ query -> getTable ( ) ; $ newGroupByFields = [ ] ; foreach ( $ groupByFields as $ field ) { if ( $ field == '*' ) { foreach ( $ namesMap as $ aliasName => $ columnName ) { $ newGroupByFields [ $ columnName ] = 1 ; } continue ; } else if ( ! empty ( $ originalSource ) && $ field == "$originalSource.*" ) { foreach ( $ namesMap as $ aliasName => $ columnName ) { $ newGroupByFields [ "$source.$columnName" ] = 1 ; } continue ; } else { $ newName = $ this -> getFieldNewName ( $ field , $ namesMap , $ originalSource , $ source ) ; if ( $ newName != null ) { $ newGroupByFields [ $ newName ] = 1 ; } } } if ( ! empty ( $ newGroupByFields ) ) { $ query -> groupByFields ( array_keys ( $ newGroupByFields ) ) ; } } } | Renombra los campos involucrados en agrupamiento segun el mapa indicado |
27,243 | private function renameJoinFields ( SelectQuery $ query , $ namesMap = null , $ originalSource = null ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ joins = & $ query -> getJoins ( ) ; if ( ! empty ( $ joins ) ) { foreach ( $ joins as & $ join ) { $ this -> renameConditionFields ( $ join , $ namesMap , $ originalSource , $ query -> getTable ( ) ) ; } } } | Renombra los campos involucrados en joins segun el mapa indicado |
27,244 | private function hasOtherConditionField ( ConditionGroup $ conditionGroup , string $ source , array $ fieldNames , & $ foundField = null ) : bool { $ result = false ; $ conditions = & $ conditionGroup -> getConditions ( ) ; foreach ( $ conditions as $ key => & $ condition ) { if ( $ condition -> type == ConditionType :: GROUP ) { $ result = $ this -> hasOtherConditionField ( $ condition -> group , $ source , $ fieldNames , $ foundField ) ; if ( $ result ) { break ; } } else if ( $ condition -> type == ConditionType :: RAW ) { $ result = true ; $ foundField = 'RAW' ; break ; } else { $ field = $ condition -> field ; $ tablePos = stripos ( $ field , "$source." ) ; if ( $ tablePos === 0 ) { $ field = substr ( $ field , strlen ( $ source ) + 1 ) ; } if ( ! $ this -> fieldInList ( $ field , $ fieldNames ) ) { $ result = true ; $ foundField = $ field ; break ; } if ( $ condition -> operator == ConditionOperator :: EQUALS_FIELD ) { $ field = $ condition -> value ; $ tablePos = stripos ( $ field , "$source." ) ; if ( $ tablePos === 0 ) { $ field = substr ( $ field , strlen ( $ source ) + 1 ) ; } if ( ! $ this -> fieldInList ( $ field , $ fieldNames ) ) { $ result = true ; $ foundField = $ field ; break ; } } } } return $ result ; } | Retorna verdadero si en entre las codiciones encuentra otro field distinto a los indicados |
27,245 | private function processData ( $ target , array $ rules , $ required , & $ result ) { foreach ( $ rules as $ constraintName => $ options ) { if ( isset ( $ options [ 'value' ] ) ) { if ( is_array ( $ options [ 'value' ] ) ) { $ args = array_merge ( array ( $ constraintName ) , $ options [ 'value' ] ) ; $ constraint = call_user_func_array ( array ( $ this -> constraintFactory , 'build' ) , $ args ) ; } else { $ constraint = $ this -> constraintFactory -> build ( $ constraintName , $ options [ 'value' ] ) ; } } else { $ constraint = $ this -> constraintFactory -> build ( $ constraintName ) ; } if ( isset ( $ options [ 'break' ] ) ) { $ constraint -> setBreakable ( $ options [ 'break' ] ) ; } else { $ constraint -> setBreakable ( true ) ; } if ( isset ( $ options [ 'message' ] ) ) { $ constraint -> setMessage ( $ options [ 'message' ] ) ; } $ constraint -> setRequired ( ( bool ) $ required ) ; if ( ! isset ( $ result [ $ target ] ) ) { $ result [ $ target ] = array ( ) ; } array_push ( $ result [ $ target ] , $ constraint ) ; } } | Process an array of configuration |
27,246 | protected function addNewValues ( array $ selections , array $ values ) { if ( $ this -> isAllowAdd ( ) ) { foreach ( $ values as $ value ) { if ( ! \ in_array ( $ value , $ selections ) && ! \ in_array ( ( string ) $ value , $ selections ) ) { $ selections [ ] = ( string ) $ value ; } } } return $ selections ; } | Add new values . |
27,247 | protected function getSelectedChoices ( array $ values , $ value = null ) { $ structuredValues = $ this -> loadChoiceList ( $ value ) -> getStructuredValues ( ) ; $ values = $ this -> forceStringValues ( $ values ) ; $ allChoices = [ ] ; $ choices = [ ] ; $ isGrouped = false ; foreach ( $ structuredValues as $ group => $ choice ) { if ( \ is_array ( $ choice ) ) { $ isGrouped = true ; foreach ( $ choice as $ choiceKey => $ choiceValue ) { if ( $ this -> allChoices || \ in_array ( $ choiceValue , $ values ) ) { $ choices [ $ group ] [ $ choiceKey ] = $ choiceValue ; $ allChoices [ $ choiceKey ] = $ choiceValue ; } } } elseif ( $ this -> allChoices || \ in_array ( $ choice , $ values ) ) { $ choices [ $ group ] = $ choice ; $ allChoices [ $ group ] = $ choice ; } } if ( $ this -> isAllowAdd ( ) ) { $ choices = $ this -> addNewTagsInChoices ( $ choices , $ allChoices , $ values , $ isGrouped ) ; } return ( array ) $ choices ; } | Keep only the selected values in choices . |
27,248 | protected function forceStringValues ( array $ values ) { foreach ( $ values as $ key => $ value ) { $ values [ $ key ] = ( string ) $ value ; } return $ values ; } | Force value with string type . |
27,249 | protected function addNewTagsInChoices ( array $ choices , array $ allChoices , array $ values , $ isGrouped ) { foreach ( $ values as $ value ) { if ( ! \ in_array ( $ value , $ allChoices ) ) { if ( $ isGrouped ) { $ choices [ '-------' ] [ $ value ] = $ value ; } else { $ choices [ $ value ] = $ value ; } } } return $ choices ; } | Add new tags in choices . |
27,250 | public function render ( $ data = array ( ) , $ params = array ( ) ) { if ( $ this -> controller -> getTemplate ( ) !== null ) { foreach ( $ this -> controller -> filters as $ filter ) { $ this -> twig -> addFilter ( $ filter ) ; } $ this -> twig -> addGlobal ( 'params' , $ params ) ; $ key = "twig" . microtime ( true ) ; $ template = $ this -> twig -> load ( $ this -> controller -> getTemplate ( ) ) ; $ data = $ template -> render ( $ this -> getData ( $ data ) ) ; } return $ data ; } | Devuelve la vista renderizada |
27,251 | public function mail ( $ template , $ data = array ( ) , & $ css = array ( ) ) { $ this -> twig -> addFunction ( new \ Twig_SimpleFunction ( 'css' , function ( $ file ) use ( & $ css ) { $ css [ ] = $ file ; } ) ) ; $ template = $ this -> twig -> loadTemplate ( $ template ) ; return $ template -> render ( $ data ) ; } | Devulve una vista compatible con los clientes de correo |
27,252 | protected function getCompatibilityId ( ) { $ controller = $ this -> controller ? $ this -> controller : Yii :: $ app -> controller -> id ; if ( strpos ( $ controller , "/" ) ) { $ controller = substr ( $ controller , strpos ( $ controller , "/" ) + 1 ) ; } return str_replace ( ' ' , '' , ucwords ( str_replace ( '-' , ' ' , $ controller ) ) ) ; } | Get the simpler access privileges name from the current controller |
27,253 | protected function initDefaultButtons ( ) { $ controller = $ this -> getCompatibilityId ( ) ; if ( \ Yii :: $ app -> user -> checkAccess ( 'read::' . $ controller ) ) { if ( ! isset ( $ this -> buttons [ 'view' ] ) ) { $ this -> buttons [ 'view' ] = function ( $ url , $ model ) { return Html :: a ( '<span class="glyphicon glyphicon-eye-open"></span>' , $ url , [ 'title' => Yii :: t ( 'yii' , 'View' ) , 'class' => 'btn btn-xs btn-primary hidden-xs button-status-deactivate' , 'data-pjax' => '0' , ] ) ; } ; } } if ( \ Yii :: $ app -> user -> checkAccess ( 'update::' . $ controller ) ) { if ( ! isset ( $ this -> buttons [ 'status' ] ) ) { $ this -> buttons [ 'status' ] = function ( $ url , $ model ) { if ( $ model -> status == 'active' ) return Html :: a ( '<span class="glyphicon glyphicon-remove"></span>' , $ url , [ 'title' => Yii :: t ( 'yii' , 'Deactivate' ) , 'onclick' => 'javascript: if(confirm("Are you sure you want to deactivate this item?")) myGrid.status($(this)); return false;' , 'class' => 'btn btn-xs btn-warning hidden-xs button-status-deactivate' , 'data-pjax' => '0' , ] ) ; else return Html :: a ( '<span class="glyphicon glyphicon-ok"></span>' , $ url , [ 'title' => Yii :: t ( 'yii' , 'Activate' ) , 'onclick' => 'javascript: if(confirm("Are you sure you want to activate this item?")) myGrid.status($(this)); return false;' , 'class' => 'btn btn-xs btn-success hidden-xs button-status-activate' , 'data-pjax' => '0' , ] ) ; } ; } if ( ! isset ( $ this -> buttons [ 'update' ] ) ) { $ this -> buttons [ 'update' ] = function ( $ url , $ model ) { return Html :: a ( '<span class="glyphicon glyphicon-pencil"></span>' , $ url , [ 'title' => Yii :: t ( 'yii' , 'Update' ) , 'class' => 'btn btn-xs btn-default' , 'data-pjax' => '0' , ] ) ; } ; } } if ( \ Yii :: $ app -> user -> checkAccess ( 'delete::' . $ controller ) ) { if ( ! isset ( $ this -> buttons [ 'delete' ] ) ) { $ this -> buttons [ 'delete' ] = function ( $ url , $ model ) { return Html :: a ( '<span class="glyphicon glyphicon-trash"></span>' , $ url , [ 'title' => Yii :: t ( 'yii' , 'Delete' ) , 'onclick' => 'javascript: if(confirm("Are you sure you want to delete this item?")) myGrid.status($(this)); return false;' , 'class' => 'btn btn-xs btn-danger button-delete' , 'data-pjax' => '0' , ] ) ; } ; } } } | Initializes the default button rendering callbacks |
27,254 | public function asArray ( ) { $ array = [ ] ; foreach ( get_object_vars ( $ this ) as $ property => $ value ) { if ( empty ( $ value ) ) { continue ; } $ array [ $ property ] = $ value ; } return $ array ; } | Get an array representation of the object . |
27,255 | public function insert ( $ data = null ) { $ currentIndex = $ this -> getFieldValue ( $ this -> getIndex ( ) ) ; $ fields = $ this -> getFields ( ) ; $ sql1 = '' ; $ sql2 = '' ; $ args = array ( ) ; foreach ( $ fields as $ field ) { if ( in_array ( $ field , $ this -> created_at_fileds ) ) { $ this -> { $ field } = now ( ) ; } $ value = $ this -> getFieldValue ( $ field , $ data ) ; $ args [ $ field ] = $ value ; $ sql1 .= "`$field`, " ; $ sql2 .= ":$field, " ; } if ( ! empty ( $ sql1 ) ) { $ sql1 = substr ( $ sql1 , 0 , - 2 ) ; $ sql2 = substr ( $ sql2 , 0 , - 2 ) ; if ( $ currentIndex ) { $ this -> db -> removeCache ( $ this -> getCacheId ( $ currentIndex ) ) ; } return $ this -> db -> insert ( 'INSERT INTO `' . $ this -> table_name . '` (' . $ sql1 . ') VALUES (' . $ sql2 . ')' , $ args ) ; } return false ; } | Inserta el modelo en la tabla |
27,256 | public function update ( $ data = null ) { $ fields = $ this -> getFields ( ) ; $ sql1 = '' ; $ args = array ( ) ; foreach ( $ fields as $ field ) { if ( in_array ( $ field , $ this -> updated_at_fileds ) ) { $ this -> { $ field } = now ( ) ; } $ value = $ this -> getFieldValue ( $ field , $ data ) ; if ( isset ( $ value ) && ! $ this -> isIndex ( $ field ) ) { $ args [ ] = $ value ; $ sql1 .= "`$field` = ?, " ; } } if ( ! empty ( $ sql1 ) ) { $ sql1 = substr ( $ sql1 , 0 , - 2 ) ; $ index = $ this -> getIndex ( ) ; $ indexValue = $ this -> db -> escape_string ( $ this -> getFieldValue ( $ index , $ data ) ) ; if ( ! $ indexValue ) { return false ; } $ args [ ] = $ indexValue ; return $ this -> db -> exec ( "UPDATE `{$this->table_name}` SET $sql1 WHERE `$index` = ?" , $ args , $ this -> getCacheId ( $ indexValue ) ) ; } return false ; } | Si el modelo tiene indice actualiza el modelo con los datos |
27,257 | public function delete ( $ cache = null ) { $ index = $ this -> getIndex ( ) ; $ value = $ this -> getFieldValue ( $ index ) ; if ( $ value ) { if ( $ cache ) { $ this -> db -> removeCache ( $ this -> getCacheId ( $ cache ) ) ; } return $ this -> db -> exec ( "DELETE FROM {$this->table_name} WHERE `$index` = ?" , array ( $ value ) , $ this -> getCacheId ( $ value ) ) ; } return false ; } | Eliminar el modelo de la base de datos |
27,258 | public function get_or ( $ fields ) { $ args = array ( ) ; $ fieldsValue = $ fields ; $ fields = $ this -> getFields ( ) ; $ sql = '' ; foreach ( $ fields as $ field ) { if ( isset ( $ fieldsValue [ $ field ] ) ) { $ value = $ fieldsValue [ $ field ] ; if ( is_array ( $ value ) ) { foreach ( $ value as $ subvalue ) { $ sql .= '`' . $ field . '` = ? OR ' ; $ args [ ] = $ subvalue ; } } else { $ sql .= '`' . $ field . '` = ? OR ' ; $ args [ ] = $ value ; } } } if ( ! empty ( $ sql ) ) { $ sql = substr ( $ sql , 0 , - 4 ) ; return $ this -> build ( $ this -> db -> select ( 'SELECT * FROM `' . $ this -> table_name . '` WHERE ' . $ sql , $ args ) ) ; } return $ this -> build ( array ( ) ) ; } | Obtener el modelo de la base de datos con condiciones disyuntivas |
27,259 | public function get_all ( ) { return $ this -> build ( $ this -> db -> select ( 'SELECT * FROM `' . $ this -> table_name . '` WHERE 1' , [ ] , $ this -> getCacheId ( 'all' ) ) ) ; } | Obtener todos los modelos de la tabla |
27,260 | public function get_others ( ) { $ index = $ this -> getIndex ( ) ; $ value = $ this -> getFieldValue ( $ index ) ; if ( is_string ( $ value ) && strlen ( $ value ) > 0 ) { return $ this -> build ( $ this -> db -> select ( 'SELECT * FROM `' . $ this -> table_name . '` WHERE `' . $ index . '` != ?' , array ( ( string ) $ value ) , $ this -> getCacheId ( "not_" . $ value ) ) ) ; } return $ this -> get_all ( ) ; } | Obtener los modelos que no sean este . |
27,261 | public function search ( $ fields , $ limit = - 1 ) { if ( ! is_array ( $ fields ) ) { $ fields = array ( $ this -> getIndex ( ) => $ fields ) ; } $ fieldsValue = $ fields ; $ fields = $ this -> getFields ( ) ; $ sql = '' ; $ args = array ( ) ; foreach ( $ fields as $ field ) { if ( isset ( $ fieldsValue [ $ field ] ) ) { $ value = $ fieldsValue [ $ field ] ; if ( $ this -> isString ( $ field ) ) { $ sql .= '`' . $ field . '` LIKE ? OR ' ; $ args [ ] = '%' . $ value . '%' ; } else { $ sql .= '`' . $ field . '` = ? OR ' ; $ args [ ] = $ value ; } } } if ( ! empty ( $ sql ) ) { $ sql = substr ( $ sql , 0 , - 4 ) ; if ( $ limit > 0 ) { $ sql .= " LIMIT $limit" ; } return $ this -> build ( $ this -> db -> select ( 'SELECT * FROM `' . $ this -> table_name . '` WHERE ' . $ sql , $ args ) ) ; } return $ this -> build ( array ( ) ) ; } | Busca en forma de texto en la tabla |
27,262 | public function save ( $ updateIndex = false ) { $ this -> clearCacheTableIndex ( ) ; if ( $ this -> exists ( ) ) { return $ this -> update ( ) ; } $ result = $ this -> insert ( ) ; if ( $ result && $ updateIndex ) { $ this -> setToIndex ( $ result ) ; } return $ result ; } | Actualiza si ya existe en otro caso inserta |
27,263 | public function exists ( ) { $ indexValue = $ this -> getFieldValue ( $ this -> getIndex ( ) ) ; if ( $ indexValue ) { return $ this -> get ( $ indexValue ) -> count ( ) > 0 ; } return false ; } | Devuelve true si existe el modelo en la tabla |
27,264 | public function getFieldValue ( $ field , $ data = null ) { if ( $ data !== null && isset ( $ data [ $ field ] ) ) { return $ data [ $ field ] ; } if ( isset ( $ this -> { $ field } ) ) { return $ this -> { $ field } ; } return null ; } | Obtiene el valor del campo especificado null si no existe el campo |
27,265 | public function getFields ( ) { $ fields = array ( ) ; if ( isset ( $ this -> definition [ 'index' ] ) ) { $ fields [ ] = $ this -> getIndex ( ) ; } if ( isset ( $ this -> definition [ 'fields' ] ) ) { foreach ( $ this -> definition [ 'fields' ] as $ key => $ value ) { if ( ! is_numeric ( $ key ) ) { $ fields [ ] = $ key ; } else { $ fields [ ] = $ value ; } } } return $ fields ; } | Apartir de la definicion devuelve los campos disponibles para el modelo |
27,266 | public function build ( $ result ) { $ modelResult = new ModelResult ( $ this ) ; $ modelResult -> models = $ result ; if ( count ( $ result ) > 0 ) { $ modelResult -> model = $ result [ 0 ] ; } if ( $ this -> order !== '' ) { $ modelResult -> order ( $ this -> order ) ; } return $ modelResult ; } | Genera un resultado de modelos a partir de la lista develta por la consulta |
27,267 | public function setData ( $ data , $ allowEmpty = true , $ allowUnset = false ) { if ( $ data != null ) { if ( is_array ( $ data ) ) { $ fileds = $ this -> getFields ( ) ; foreach ( $ fileds as $ field ) { if ( isset ( $ data [ $ field ] ) && ( $ allowEmpty || $ data [ $ field ] !== '' ) ) { if ( strpos ( $ this -> getFieldType ( $ field ) , 'varchar' ) !== false || $ this -> getFieldType ( $ field ) === 'text' ) { $ encoding = mb_detect_encoding ( $ data [ $ field ] ) ; if ( $ encoding !== 'utf8' ) { $ this -> { $ field } = mb_convert_encoding ( $ data [ $ field ] , 'utf8' , $ encoding ) ; } else { $ this -> { $ field } = $ data [ $ field ] ; } } else { $ this -> { $ field } = $ data [ $ field ] ; } } elseif ( $ allowUnset ) { $ this -> { $ field } = false ; } } } else { $ result = $ this -> get ( $ data ) ; $ this -> setData ( $ result -> model ) ; if ( empty ( $ result -> model ) ) { $ this -> asDefault ( ) ; } } } if ( empty ( $ data ) ) { $ this -> asDefault ( ) ; } return $ this ; } | Establecer estos datos al modelo en funcion de la definicion si no esta en la definicion no se asigna al modelo . |
27,268 | public function getFieldDefinition ( $ field ) { if ( isset ( $ this -> definition [ $ field ] ) ) { return $ this -> definition [ $ field ] ; } if ( isset ( $ this -> definition [ 'fields' ] [ $ field ] ) ) { return $ this -> definition [ 'fields' ] [ $ field ] ; } return null ; } | Obtiene la definicion para este campo |
27,269 | public function getFieldType ( $ field ) { $ definition = $ this -> getFieldDefinition ( $ field ) ; if ( $ definition && isset ( $ definition [ 'type' ] ) ) { return $ definition [ 'type' ] ; } } | Obtiene el tipo para el campo |
27,270 | public function getStructureDifferences ( $ db , $ drop = false ) { $ diff = new DBStructure ( ) ; $ excepted = $ diff -> getDefinition ( $ this ) ; return $ diff -> getStructureDifferences ( $ db , $ excepted , $ drop ) ; } | Genera las diferencias entre este modelo y lo que hay en la base de datos . |
27,271 | public static function makeResult ( $ data , $ message ) { $ result = array ( ) ; $ result [ 'flag' ] = true ; $ result [ 'message' ] = $ message ; $ result [ 'data' ] = $ data ; return $ result ; } | Generates result response object |
27,272 | public static function build ( $ serviceAddress , $ restConfigPath , array $ config = [ ] ) { $ config += [ 'httpHandler' => null , ] ; list ( $ baseUri , $ port ) = self :: normalizeServiceAddress ( $ serviceAddress ) ; $ requestBuilder = new RequestBuilder ( "$baseUri:$port" , $ restConfigPath ) ; $ httpHandler = $ config [ 'httpHandler' ] ? : self :: buildHttpHandlerAsync ( ) ; return new RestTransport ( $ requestBuilder , $ httpHandler ) ; } | Builds a RestTransport . |
27,273 | public function getCollectionSize ( ) { $ size = 0 ; foreach ( $ this -> pageList as $ page ) { $ size += $ page -> getPageElementCount ( ) ; } return $ size ; } | Returns the number of elements in the collection . This will be equal to the collectionSize parameter used at construction unless there are no elements remaining to be retrieved . |
27,274 | public function getNextCollection ( ) { $ lastPage = $ this -> getLastPage ( ) ; $ nextPage = $ lastPage -> getNextPage ( $ this -> collectionSize ) ; return new FixedSizeCollection ( $ nextPage , $ this -> collectionSize ) ; } | Retrieves the next FixedSizeCollection using one or more API calls . |
27,275 | public function iterateCollections ( ) { $ currentCollection = $ this ; yield $ this ; while ( $ currentCollection -> hasNextCollection ( ) ) { $ currentCollection = $ currentCollection -> getNextCollection ( ) ; yield $ currentCollection ; } } | Returns an iterator over FixedSizeCollections starting with this and making API calls as required until all of the elements have been retrieved . |
27,276 | public function getOperation ( $ name , $ optionalArgs = [ ] ) { $ request = new GetOperationRequest ( ) ; $ request -> setName ( $ name ) ; return $ this -> startCall ( 'GetOperation' , Operation :: class , $ optionalArgs , $ request ) -> wait ( ) ; } | Gets the latest state of a long - running operation . Clients can use this method to poll the operation result at intervals as recommended by the API service . |
27,277 | public function deleteOperation ( $ name , $ optionalArgs = [ ] ) { $ request = new DeleteOperationRequest ( ) ; $ request -> setName ( $ name ) ; return $ this -> startCall ( 'DeleteOperation' , GPBEmpty :: class , $ optionalArgs , $ request ) -> wait ( ) ; } | Deletes a long - running operation . This method indicates that the client is no longer interested in the operation result . It does not cancel the operation . If the server doesn t support this method it returns google . rpc . Code . UNIMPLEMENTED . |
27,278 | private static function create ( $ basicMessage , $ rpcCode , $ metadata , array $ decodedMetadata , $ previous = null ) { $ rpcStatus = ApiStatus :: statusFromRpcCode ( $ rpcCode ) ; $ messageData = [ 'message' => $ basicMessage , 'code' => $ rpcCode , 'status' => $ rpcStatus , 'details' => $ decodedMetadata ] ; $ message = json_encode ( $ messageData , JSON_PRETTY_PRINT ) ; return new ApiException ( $ message , $ rpcCode , $ rpcStatus , [ 'previous' => $ previous , 'metadata' => $ metadata , 'basicMessage' => $ basicMessage , ] ) ; } | Construct an ApiException with a useful message including decoded metadata . |
27,279 | public static function build ( $ serviceAddress , array $ config = [ ] ) { self :: validateGrpcSupport ( ) ; $ config += [ 'stubOpts' => [ ] , 'channel' => null , 'interceptors' => [ ] , ] ; list ( $ addr , $ port ) = self :: normalizeServiceAddress ( $ serviceAddress ) ; $ host = "$addr:$port" ; $ stubOpts = $ config [ 'stubOpts' ] ; if ( ! array_key_exists ( 'credentials' , $ stubOpts ) ) { $ stubOpts [ 'credentials' ] = ChannelCredentials :: createSsl ( ) ; } $ channel = $ config [ 'channel' ] ; if ( ! is_null ( $ channel ) && ! ( $ channel instanceof Channel ) ) { throw new ValidationException ( "Channel argument to GrpcTransport must be of type \Grpc\Channel, " . "instead got: " . print_r ( $ channel , true ) ) ; } try { return new GrpcTransport ( $ host , $ stubOpts , $ channel , $ config [ 'interceptors' ] ) ; } catch ( Exception $ ex ) { throw new ValidationException ( "Failed to build GrpcTransport: " . $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex ) ; } } | Builds a GrpcTransport . |
27,280 | protected function isBinaryAvailable ( ) : bool { if ( OsHelper :: isUnix ( ) ) { $ process = new Process ( [ 'sh' , '-c' , 'command -v $0' , $ this -> getBinary ( ) , ] ) ; } else { $ process = new Process ( [ 'where' , $ this -> getBinary ( ) , ] ) ; } $ process -> run ( ) ; return $ process -> isSuccessful ( ) ; } | Check whether a binary is available . |
27,281 | public static function extractFile ( string $ filePath , bool $ overwrite = false ) : string { $ pharPath = \ Phar :: running ( false ) ; if ( empty ( $ pharPath ) ) { return '' ; } $ relativeFilePath = substr ( $ filePath , strpos ( $ filePath , $ pharPath ) + strlen ( $ pharPath ) + 1 ) ; $ tmpDir = sys_get_temp_dir ( ) . '/jolinotif' ; $ extractedFilePath = $ tmpDir . '/' . $ relativeFilePath ; if ( ! file_exists ( $ extractedFilePath ) || $ overwrite ) { $ phar = new \ Phar ( $ pharPath ) ; $ phar -> extractTo ( $ tmpDir , $ relativeFilePath , $ overwrite ) ; } return $ extractedFilePath ; } | Extract the file from the phar archive to make it accessible for native commands . |
27,282 | protected function _getToken ( $ index , $ type ) { if ( $ index === null ) { $ index = $ this -> _current ; } return isset ( $ this -> _data [ $ index ] ) ? $ this -> _data [ $ index ] [ $ type ] : null ; } | Returns the current token value . |
27,283 | public function getName ( $ index = null ) { $ type = $ this -> getType ( $ index ) ; return is_int ( $ type ) ? token_name ( $ type ) : null ; } | Returns the token type name . |
27,284 | public function current ( $ token = false ) { if ( ! $ this -> valid ( ) ) { return null ; } return $ token ? $ this -> _data [ $ this -> _current ] : $ this -> _data [ $ this -> _current ] [ 1 ] ; } | Returns the current token or the token value . |
27,285 | public function next ( $ type = false ) { if ( $ type === false || $ type === true ) { $ this -> _current ++ ; return $ this -> current ( $ type ) ; } $ content = '' ; $ start = $ this -> _current ++ ; $ count = $ this -> count ( ) ; $ list = array_fill_keys ( ( array ) $ type , true ) ; while ( $ this -> _current < $ count ) { $ content .= $ this -> _data [ $ this -> _current ] [ 1 ] ; if ( isset ( $ list [ $ this -> _data [ $ this -> _current ] [ 0 ] ] ) ) { return $ content ; } $ this -> _current ++ ; } $ this -> _current = $ start ; } | Move to the next token of a given type . |
27,286 | public function nextSequence ( $ sequence ) { $ start = $ this -> _current ; $ result = '' ; $ len = strlen ( $ sequence ) ; $ lastToken = substr ( $ sequence , - 1 ) ; while ( ( $ content = $ this -> next ( $ lastToken ) ) !== null ) { $ result .= $ content ; if ( strlen ( $ result ) >= $ len && substr_compare ( $ result , $ sequence , - $ len , $ len ) === 0 ) { return $ result ; } } $ this -> _current = $ start ; } | Moves to the next sequence of tokens . |
27,287 | public function nextMatchingBracket ( ) { if ( ! $ this -> valid ( ) ) { return ; } $ matches = [ '(' => ')' , '{' => '}' , '[' => ']' ] ; $ token = $ this -> current ( ) ; $ content = $ open = $ token [ 0 ] ; if ( ! isset ( $ matches [ $ open ] ) ) { return ; } $ level = 1 ; $ close = $ matches [ $ open ] ; $ start = $ this -> _current ; $ count = $ this -> count ( ) ; $ this -> _current ++ ; while ( $ this -> _current < $ count ) { $ type = $ this -> _data [ $ this -> _current ] [ 0 ] ; if ( $ type === $ close ) { $ level -- ; } elseif ( $ type === $ open ) { $ level ++ ; } $ content .= $ this -> _data [ $ this -> _current ] [ 1 ] ; if ( $ level === 0 ) { return $ content ; } $ this -> _current ++ ; } $ this -> _current = $ start ; } | Move to the next matching bracket . |
27,288 | public function skipWhitespaces ( $ skipComment = false ) { $ skips = [ T_WHITESPACE => true ] ; if ( ! $ skipComment ) { $ skips += [ T_COMMENT => true , T_DOC_COMMENT => true ] ; } $ this -> _current ++ ; return $ this -> _skip ( $ skips ) ; } | Skips whitespaces and comments next to the current position . |
27,289 | protected function _skip ( $ skips ) { $ skipped = '' ; $ count = $ this -> count ( ) ; while ( $ this -> _current < $ count ) { if ( ! isset ( $ skips [ $ this -> _data [ $ this -> _current ] [ 0 ] ] ) ) { break ; } $ skipped .= $ this -> _data [ $ this -> _current ] [ 1 ] ; $ this -> _current ++ ; } return $ skipped ; } | Skips elements until an element doesn t match the elements in the passed array . |
27,290 | public function seek ( $ index , $ token = false ) { $ this -> _current = ( int ) $ index ; return $ this -> current ( $ token ) ; } | Move to a specific index . |
27,291 | public function source ( $ start = null , $ end = null ) { $ source = '' ; $ start = ( int ) $ start ; $ end = $ end === null ? ( $ this -> count ( ) - 1 ) : ( int ) $ end ; for ( $ i = $ start ; $ i <= $ end ; $ i ++ ) { $ source .= $ this -> _data [ $ i ] [ 1 ] ; } return $ source ; } | Returns the stream content . |
27,292 | public function toReceive ( ) { if ( ! $ this -> _isClass ) { throw new Exception ( "Error `toReceive()` are only available on classes/instances not functions." ) ; } return $ this -> _method = $ this -> _stub -> method ( func_get_args ( ) ) ; } | Stub a chain of methods . |
27,293 | public static function write ( $ options ) { $ defaults = [ 'file' => null ] ; $ options += $ defaults ; if ( ! $ options [ 'file' ] ) { throw new RuntimeException ( "Missing file name" ) ; } return file_put_contents ( $ options [ 'file' ] , static :: export ( $ options ) ) ; } | Writes a coverage to an ouput file . |
27,294 | protected static function _exportFile ( $ xmlDocument , $ file , $ data ) { $ xmlFile = $ xmlDocument -> createElement ( 'file' ) ; $ xmlFile -> setAttribute ( 'name' , $ file ) ; foreach ( $ data as $ line => $ node ) { $ xmlLine = $ xmlDocument -> createElement ( 'line' ) ; $ xmlLine -> setAttribute ( 'num' , $ line + 1 ) ; $ xmlLine -> setAttribute ( 'type' , 'stmt' ) ; $ xmlLine -> setAttribute ( 'count' , $ data [ $ line ] ) ; $ xmlFile -> appendChild ( $ xmlLine ) ; } return $ xmlFile ; } | Export the coverage of a file . |
27,295 | protected static function _exportMetrics ( $ xmlDocument , $ metrics ) { $ data = $ metrics -> data ( ) ; $ xmlMetrics = $ xmlDocument -> createElement ( 'metrics' ) ; $ xmlMetrics -> setAttribute ( 'loc' , $ data [ 'loc' ] ) ; $ xmlMetrics -> setAttribute ( 'ncloc' , $ data [ 'nlloc' ] ) ; $ xmlMetrics -> setAttribute ( 'statements' , $ data [ 'lloc' ] ) ; $ xmlMetrics -> setAttribute ( 'coveredstatements' , $ data [ 'cloc' ] ) ; return $ xmlMetrics ; } | Export the coverage of a metrics . |
27,296 | public static function run ( $ callable , $ timeout = 0 ) { if ( ! is_callable ( $ callable ) ) { throw new InvalidArgumentException ( ) ; } $ timeout = ( integer ) $ timeout ; if ( ! function_exists ( 'pcntl_signal' ) ) { throw new Exception ( "PCNTL threading is not supported by your system." ) ; } pcntl_signal ( SIGALRM , function ( $ signal ) use ( $ timeout ) { throw new TimeoutException ( "Timeout reached, execution aborted after {$timeout} second(s)." ) ; } , true ) ; pcntl_alarm ( $ timeout ) ; $ result = null ; try { $ result = $ callable ( ) ; pcntl_alarm ( 0 ) ; } catch ( Throwable $ e ) { pcntl_alarm ( 0 ) ; throw $ e ; } catch ( Exception $ e ) { pcntl_alarm ( 0 ) ; throw $ e ; } return $ result ; } | Executes a callable until a timeout is reached or the callable returns true . |
27,297 | public static function spin ( $ callable , $ timeout = 0 , $ delay = 100000 ) { if ( ! is_callable ( $ callable ) ) { throw new InvalidArgumentException ( ) ; } $ closure = function ( ) use ( $ callable , $ timeout , $ delay ) { $ timeout = ( float ) $ timeout ; $ start = microtime ( true ) ; do { if ( $ result = $ callable ( ) ) { return $ result ; } usleep ( $ delay ) ; $ current = microtime ( true ) ; } while ( $ current - $ start < $ timeout ) ; throw new TimeoutException ( "Timeout reached, execution aborted after {$timeout} second(s)." ) ; } ; if ( ! function_exists ( 'pcntl_signal' ) ) { return $ closure ( ) ; } return static :: run ( $ closure , $ timeout ) ; } | Executes a callable in a loop until a timeout is reached or the callable returns true . |
27,298 | public static function quit ( $ status = 0 ) { if ( static :: enabled ( ) ) { exit ( $ status ) ; } if ( ! is_numeric ( $ status ) ) { throw new QuitException ( 'Exit statement occurred with message: ' . $ status , 0 ) ; } throw new QuitException ( 'Exit statement occurred' , $ status ) ; } | Run a controlled quit statement . |
27,299 | public function process ( & $ return = null ) { if ( $ this -> _passed === null ) { $ this -> _process ( ) ; } $ return = $ this -> _return ; return $ this -> _passed ; } | Checks if all test passed . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.