idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
5,200
public function returnTypeAsString ( ) { $ myPackage = & $ this -> containingPackage ( ) ; $ classDoc = & $ this -> _returnType -> asClassDoc ( ) ; if ( $ classDoc ) { $ packageDoc = & $ classDoc -> containingPackage ( ) ; return '<a href="' . str_repeat ( '../' , $ myPackage -> depth ( ) + 1 ) . $ classDoc -> asPath (...
Format a return type for outputting . Recognised types are turned into HTML anchor tags to the documentation page for the class defining them .
5,201
private function getActionParams ( ) { $ result = '' ; $ requestParams = Yii :: $ app -> request -> getParams ( ) ; ArrayHelper :: remove ( $ requestParams , 0 ) ; foreach ( $ requestParams as $ key => $ value ) { if ( is_string ( $ key ) ) { $ result .= " --{$key}={$value}" ; } else { $ result .= " {$value}" ; } } ret...
Get action params
5,202
public function init ( $ appKey , $ username , $ password ) { if ( $ appKey == self :: $ appKey && $ this -> sessionRemaining ( ) > 5 ) { $ this -> keepAlive ( ) ; } else { $ this -> login ( $ appKey , $ username , $ password ) ; } }
Wrapper method for other methods to initiate and manage a Betfair session . This method can be called safely multiple times in a script or in a loop for a long running process and will only trigger the authentication overhead when really needed .
5,203
public function persist ( $ appKey , $ sessionToken ) { if ( $ sessionToken === null ) { throw new Exception ( 'Invalid session token' ) ; } self :: $ appKey = $ appKey ; self :: $ sessionToken = $ sessionToken ; return $ this -> keepAlive ( ) ; }
Accept app key and session token and extend session .
5,204
public function keepAlive ( ) { $ result = $ this -> execute ( $ this -> httpClient -> setEndPoint ( self :: ENDPOINT . 'keepAlive/' ) ) ; self :: $ lastLogin = time ( ) ; return $ result -> token ; }
Execute Betfair API call to extend the current session . Implicitly uses the already set app key and session token .
5,205
public function logout ( ) { $ this -> execute ( $ this -> httpClient -> setEndPoint ( self :: ENDPOINT . 'logout/' ) ) ; self :: $ appKey = null ; self :: $ sessionToken = null ; self :: $ lastLogin = null ; }
Execute Betfair API call to logout from their system . Clear all local references to the session .
5,206
public function execute ( $ request ) { $ result = $ request -> authHeaders ( ) -> send ( ) ; if ( $ result -> status === self :: API_STATUS_FAIL ) { throw new Exception ( 'Error: ' . $ result -> error ) ; } return $ result ; }
Accept request add auth headers and dispatch then respond to any errors .
5,207
public function log ( $ message , $ type = self :: MESSAGE_INFO ) { $ format = [ $ type == self :: MESSAGE_ERROR ? Console :: FG_RED : Console :: FG_BLUE ] ; Console :: stdout ( Console :: ansiFormat ( $ message . PHP_EOL , $ format ) ) ; }
Logs info and error messages .
5,208
public function editUserRoles ( $ id ) { if ( Shinobi :: can ( config ( 'watchtower.acl.user.role' , false ) ) ) { $ user = $ this -> model :: findOrFail ( $ id ) ; $ roles = $ user -> roles ; $ available_roles = Role :: whereDoesntHave ( 'users' , function ( $ query ) use ( $ id ) { $ query -> where ( 'user_id' , $ id...
Show the form for editing the user roles .
5,209
public function _processInlineTags ( & $ tag , $ first = FALSE ) { $ description = '' ; if ( is_array ( $ tag ) ) $ tag = $ tag [ 0 ] ; if ( is_object ( $ tag ) ) { if ( $ first ) { $ tags = & $ tag -> firstSentenceTags ( $ this -> _doclet ) ; } else { $ tags = & $ tag -> inlineTags ( $ this -> _doclet ) ; } if ( $ tag...
Convert inline tags into a string for outputting .
5,210
public function frameOutputWriter ( & $ doclet ) { parent :: HTMLWriter ( $ doclet ) ; ob_start ( ) ; echo <<<END<frameset cols="20%,80%" frameborder="1" border="1" bordercolor="#bbb" framespacing="1"><frame src="frame.html" name="index"><frame src="namespaces.html" name="main"><noframes> <body> <h2>Frame Al...
Build the HTML frameset .
5,211
public function run ( ) { $ searchModel = Yii :: createObject ( $ this -> searchClass ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; return $ this -> controller -> render ( $ this -> view , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
Lists of all cron logs .
5,212
public function addSource ( $ filename , $ source , $ fileData ) { $ this -> _sources [ substr ( $ filename , strlen ( $ this -> _phpdoctor -> sourcePath ( ) ) + 1 ) ] = array ( $ source , $ fileData ) ; }
Add a source file to this root .
5,213
function & classes ( ) { $ classes = array ( ) ; $ packages = $ this -> packages ( ) ; foreach ( $ packages as $ name => $ package ) { $ packageClasses = $ this -> _packages [ $ name ] -> allClasses ( ) ; if ( $ packageClasses ) { foreach ( $ packageClasses as $ key => $ pack ) { $ classes [ $ key . '.' . $ name ] = & ...
Return a reference to the classes and interfaces to be documented .
5,214
function & functions ( ) { $ functions = array ( ) ; $ packages = $ this -> packages ( ) ; foreach ( $ packages as $ name => $ package ) { $ packageFunctions = $ this -> _packages [ $ name ] -> functions ( ) ; if ( $ packageFunctions ) { foreach ( $ packageFunctions as $ key => $ pack ) { $ functions [ $ name . '.' . $...
Return a reference to the functions to be documented .
5,215
function & globals ( ) { $ globals = array ( ) ; $ packages = $ this -> packages ( ) ; foreach ( $ packages as $ name => $ package ) { $ packageGlobals = $ this -> _packages [ $ name ] -> globals ( ) ; if ( $ packageGlobals ) { foreach ( $ packageGlobals as $ key => $ pack ) { $ globals [ $ name . '.' . $ key ] = & $ p...
Return a reference to the globals to be documented .
5,216
function & packageNamed ( $ name , $ create = FALSE ) { $ return = NULL ; if ( isset ( $ this -> _packages [ $ name ] ) ) { $ return = & $ this -> _packages [ $ name ] ; } elseif ( $ create ) { $ newPackage = & new packageDoc ( $ name , $ this ) ; $ this -> addPackage ( $ newPackage ) ; $ return = & $ newPackage ; } re...
Return a reference to a packageDoc for the specified package name . If a package of the requested name does not exist this method will create the package object add it to the root and return it .
5,217
public function checkIsMutexAction ( $ action ) { return in_array ( strtolower ( $ action ) , $ this -> mutexActions ) || in_array ( '*' , $ this -> mutexActions ) ; }
Checks if specified action is among mutex actions .
5,218
public function performQuery ( ) { if ( $ this -> option ( 'c' ) ) { $ this -> schema -> setConnection ( $ this -> option ( 'c' ) ) ; $ this -> schema -> switchWrapper ( ) ; } $ rawQuery = $ this -> option ( 'r' ) ; if ( empty ( $ rawQuery ) ) { $ this -> warn ( 'Please provide raw sql query as string (in single/double...
Perform raw sql query
5,219
public function _linkText ( $ link , $ doclet ) { $ element = & $ this -> _resolveLink ( ) ; if ( $ element && $ this -> _parent ) { $ package = & $ this -> _parent -> containingPackage ( ) ; $ path = str_repeat ( '../' , $ package -> depth ( ) + 1 ) . $ element -> asPath ( ) ; return $ doclet -> formatLink ( $ path , ...
Generate the text to go into the seeTag link
5,220
public function inheritFields ( & $ element , & $ rootDoc , & $ package ) { $ fields = & $ element -> fields ( ) ; if ( $ fields ) { ksort ( $ fields ) ; $ num = count ( $ fields ) ; $ foo = 0 ; echo '<table class="inherit">' , "\n" ; echo '<tr><th colspan="2">Fields inherited from ' , $ element -> qualifiedName ( ) , ...
Display the inherited fields of an element . This method calls itself recursively if the element has a parent class .
5,221
public function inheritMethods ( & $ element , & $ rootDoc , & $ package ) { $ methods = & $ element -> methods ( ) ; if ( $ methods ) { ksort ( $ methods ) ; $ num = count ( $ methods ) ; $ foo = 0 ; echo '<table class="inherit">' , "\n" ; echo '<tr><th colspan="2">Methods inherited from ' , $ element -> qualifiedName...
Display the inherited methods of an element . This method calls itself recursively if the element has a parent class .
5,222
public function _nav ( $ path ) { $ output = '<div class="header">' . "\n" ; $ output .= '<h1>' . $ this -> _doclet -> getHeader ( ) . "</h1>\n" ; if ( $ this -> _sections ) { $ output .= "<ul>\n" ; foreach ( $ this -> _sections as $ section ) { if ( isset ( $ section [ 'selected' ] ) && $ section [ 'selected' ] ) { $ ...
Build the navigation bar
5,223
public function _write ( $ path , $ title , $ shell ) { $ phpdoctor = & $ this -> _doclet -> phpdoctor ( ) ; $ path = str_replace ( '/' , DIRECTORY_SEPARATOR , $ path ) ; $ dirs = explode ( DIRECTORY_SEPARATOR , $ path ) ; array_pop ( $ dirs ) ; $ testPath = $ this -> _doclet -> destinationPath ( ) ; foreach ( $ dirs a...
Write the HTML page to disk using the given path .
5,224
public function _processTags ( & $ tags ) { $ tagString = '' ; foreach ( $ tags as $ key => $ tag ) { if ( $ key != '@text' ) { if ( is_array ( $ tag ) ) { $ hasText = FALSE ; foreach ( $ tag as $ key => $ tagFromGroup ) { if ( $ tagFromGroup -> text ( $ this -> _doclet ) != '' ) { $ hasText = TRUE ; } } if ( $ hasText...
Format tags for output .
5,225
public function startCronSchedule ( $ jobCode , $ status = CronScheduleStatus :: RUN , $ messages = null ) { $ this -> jobCode = $ jobCode ; $ this -> status = $ status ; $ this -> messages = $ messages ; $ this -> dateCreated = Yii :: $ app -> formatter -> asDatetime ( time ( ) , 'php: Y-m-d H:i:s' ) ; return $ this -...
Start cron schedule
5,226
public function endCronSchedule ( $ status , $ messages = null ) { if ( $ this -> id ) { $ this -> dateFinished = Yii :: $ app -> formatter -> asDatetime ( time ( ) , 'php: Y-m-d H:i:s' ) ; $ this -> status = $ status ; $ this -> messages = $ messages ; return $ this -> save ( ) ; } return false ; }
End cron schedule
5,227
public function showSchemaInTable ( ) { if ( $ this -> option ( 'c' ) ) { $ this -> schema -> setConnection ( $ this -> option ( 'c' ) ) ; $ this -> schema -> switchWrapper ( ) ; } $ tables = $ this -> schema -> databaseWrapper -> getTables ( ) ; $ headers = $ this -> schema -> headers ; if ( ! count ( $ tables ) ) { $...
Display schema information in tabular form
5,228
private static function parseline ( $ string ) { $ string = str_replace ( chr ( 10 ) , "\\n" , $ string ) ; $ string = str_replace ( chr ( 13 ) , "\\n" , $ string ) ; $ string = str_replace ( "\f" , "\\f" , $ string ) ; return $ string ; }
Replace the line break to character to parse the data correctly
5,229
protected static function replaceWithRule ( $ rule , $ output ) { foreach ( $ rule as $ data ) { $ from_json = $ data [ "from" ] ; if ( strpos ( $ from_json , chr ( 13 ) ) !== false ) { $ from_json = self :: parseline ( $ from_json ) ; } $ from = "~" . json_decode ( '"' . $ from_json . '"' ) . "~u" ; $ to = json_decode...
Replace the string with rules .
5,230
protected function __storeData ( $ key , $ value = null ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = $ value ; } else { parent :: __storeData ( $ key , $ value ) ; } }
Var Export Method
5,231
public function jsonUnSerialize ( \ SwaggerValidator \ Common \ Context $ context , $ jsonData ) { if ( ! is_object ( $ jsonData ) ) { $ context -> throwException ( 'Mismatching type of JSON Data received' , __METHOD__ , __LINE__ ) ; } if ( ! ( $ jsonData instanceof \ stdClass ) ) { $ context -> throwException ( 'Misma...
Unserialize the JSON mixed data to this swagger object type
5,232
public function jsonSerialize ( ) { $ keyDefinition = \ SwaggerValidator \ Common \ FactorySwagger :: KEY_DEFINITIONS ; $ doc = json_decode ( \ SwaggerValidator \ Common \ Collection :: jsonEncode ( parent :: jsonSerialize ( ) ) ) ; $ doc -> $ keyDefinition = json_decode ( \ SwaggerValidator \ Common \ Collection :: js...
Method call when a json_encode of an instance of this object is used
5,233
public function validate ( \ SwaggerValidator \ Common \ Context $ context ) { if ( ! $ this -> validateBaseSwagger ( $ context ) ) { return false ; } $ keyPath = \ SwaggerValidator \ Common \ FactorySwagger :: KEY_PATHS ; $ context -> logValidate ( get_class ( $ this ) , __METHOD__ , __LINE__ ) ; $ result = $ this -> ...
Validate the Request or Response
5,234
protected function checkSwaggerVersion ( \ SwaggerValidator \ Common \ Context $ context ) { if ( $ context -> getDataValue ( ) != '2.0' ) { return $ context -> setValidationError ( \ SwaggerValidator \ CustomIOHelper :: VALIDATION_TYPE_SWAGGER_ERROR , 'Bad swagger version' , __METHOD__ , __LINE__ ) ; } return true ; }
Check the Swagger Version for validate method
5,235
protected function checkSchemes ( \ SwaggerValidator \ Common \ Context $ context ) { if ( ! isset ( $ this -> schemes ) ) { return true ; } foreach ( $ this -> schemes as $ oneScheme ) { if ( strtolower ( $ context -> getDataValue ( ) ) && strtolower ( $ oneScheme ) ) { return true ; } } return $ context -> setValidat...
Check the scheme used in the request URL for validate method
5,236
protected function checkHost ( \ SwaggerValidator \ Common \ Context $ context ) { if ( ! isset ( $ this -> host ) ) { return true ; } if ( $ context -> getDataValue ( ) === null ) { return true ; } if ( strtolower ( $ context -> getDataValue ( ) ) && strtolower ( $ this -> host ) ) { return true ; } return $ context -...
Check the host used in the request URL for validate method
5,237
protected function checkBasePath ( \ SwaggerValidator \ Common \ Context $ context ) { if ( ! isset ( $ this -> basePath ) || $ this -> basePath == '/' ) { $ context -> setBasePath ( null ) ; $ context -> setRequestPath ( $ context -> getDataValue ( ) ) ; return $ context ; } if ( substr ( $ context -> getDataValue ( )...
Check the basePath used in the request URL for validate method
5,238
protected function checkConsume ( \ SwaggerValidator \ Common \ Context $ context ) { if ( ! isset ( $ this -> consume ) ) { return true ; } $ headers = $ context -> getRequestHeader ( ) ; $ contentType = null ; $ contentLength = 0 ; if ( array_key_exists ( 'Content-Type' , $ headers ) ) { $ contentType = explode ( ';'...
Check the Content - Type used in the request regarding the consume definition for validate method
5,239
public function getModel ( \ SwaggerValidator \ Common \ Context $ context ) { $ generalItems = $ this -> getMethodGeneric ( $ context , __FUNCTION__ ) ; $ paths = \ SwaggerValidator \ Common \ FactorySwagger :: KEY_PATHS ; $ context -> logModel ( __METHOD__ , __LINE__ ) ; return $ this -> $ paths -> getModel ( $ conte...
Build a model following current definition instancied
5,240
public static function getMessageByCode ( int $ code ) : string { return ( array_key_exists ( $ code , self :: MESSAGES ) ) ? self :: MESSAGES [ $ code ] : self :: MESSAGES [ self :: UNKNOWN_ERROR ] ; }
Returns error description for given code .
5,241
public static function getCodeByMessage ( string $ errorMessage ) : int { $ code = array_search ( $ errorMessage , self :: MESSAGES ) ; if ( $ code === false ) { $ code = self :: UNKNOWN_ERROR ; } return ( int ) $ code ; }
Returns error code from given error message .
5,242
public static function isAccountAddressValid ( string $ address ) : bool { if ( 1 === preg_match ( '/^[0-9a-fA-F]{4}-[0-9a-fA-F]{8}-([0-9a-fA-F]{4}|XXXX)$/' , $ address ) ) { $ checksum = strtoupper ( substr ( $ address , - 4 ) ) ; if ( 'XXXX' === $ checksum ) { return true ; } $ nodeId = substr ( $ address , 0 , 4 ) ;...
Checks if account address is in proper format .
5,243
public static function setConfigDropAllDebugLog ( ) { self :: setConfig ( 'log' , 'loadFile' , false ) ; self :: setConfig ( 'log' , 'loadRef' , false ) ; self :: setConfig ( 'log' , 'replaceRef' , false ) ; self :: setConfig ( 'log' , 'registerRef' , false ) ; self :: setConfig ( 'log' , 'dropRef' , false ) ; self :: ...
Method to disable all debug log
5,244
public static function getConfig ( $ optionGroup , $ optionName ) { if ( ! array_key_exists ( $ optionGroup , self :: $ config ) || ! is_array ( self :: $ config [ $ optionGroup ] ) ) { return ; } if ( ! array_key_exists ( $ optionName , self :: $ config [ $ optionGroup ] ) ) { return ; } return self :: $ config [ $ op...
Retrieve a config value
5,245
public function checkDataIsEmpty ( ) { if ( $ this -> isDataExists ( ) === false ) { $ this -> contextDataEmpty = true ; } elseif ( is_object ( $ this -> getDataValue ( ) ) ) { $ this -> contextDataEmpty = false ; } elseif ( is_array ( $ this -> getDataValue ( ) ) ) { $ this -> contextDataEmpty = false ; } elseif ( is_...
Check if the loaded data are empty or not
5,246
public function dataLoad ( ) { $ paramName = $ this -> __get ( 'DataPath' ) ; $ paramName = array_pop ( $ paramName ) ; $ this -> contextDataExists = false ; $ this -> contextDataValue = null ; if ( $ paramName === \ SwaggerValidator \ Common \ FactorySwagger :: LOCATION_BODY && $ this -> getType ( ) === self :: TYPE_R...
Load data and check it based on local context definition
5,247
public function loadRequestFormData ( $ paramName ) { if ( array_key_exists ( $ paramName , $ _POST ) ) { $ this -> contextDataExists = true ; $ this -> contextDataValue = $ _POST [ $ paramName ] ; } elseif ( array_key_exists ( $ paramName , $ _FILES ) ) { $ this -> contextDataExists = true ; $ this -> contextDataValue...
Filtering the request form data and files load the data and check it
5,248
public function loadRequestPath ( $ paramName ) { $ path = array_reverse ( explode ( '/' , $ this -> contextRequestPath ) ) ; $ datapath = $ this -> __get ( 'DataPath' ) ; $ partDataPath = null ; while ( true ) { if ( ! is_array ( $ datapath ) || empty ( $ datapath ) ) { $ partDataPath = null ; break ; } $ partDataPath...
Filtering the request path to identify the path parameters load the data and check it
5,249
public function getRequestQueryKey ( ) { $ uri = explode ( '?' , $ this -> getEnv ( 'REQUEST_URI' ) ) ; array_shift ( $ uri ) ; parse_str ( implode ( '?' , $ uri ) , $ qrs ) ; return array_keys ( $ qrs ) ; }
return the complete list of all params send in query string
5,250
public function loadRequestQuery ( $ paramName ) { $ uri = explode ( '?' , $ this -> getEnv ( 'REQUEST_URI' ) ) ; array_shift ( $ uri ) ; $ uri = implode ( '?' , $ uri ) ; $ qrs = $ this -> parseQueryAsMulti ( $ uri ) ; if ( array_key_exists ( $ paramName , $ qrs ) ) { $ this -> contextDataExists = true ; $ this -> con...
Filtering the request querystring load the data and check it
5,251
public function loadRequestHeader ( $ paramName ) { $ headers = $ this -> getRequestHeader ( ) ; if ( array_key_exists ( $ paramName , $ headers ) ) { $ this -> contextDataExists = true ; $ this -> contextDataValue = $ headers [ $ paramName ] ; } return $ this -> checkDataIsEmpty ( ) ; }
Filtering the request header load the data and check it
5,252
public function loadResponseHeader ( $ paramName ) { $ headers = $ this -> getResponseHeader ( ) ; if ( array_key_exists ( $ paramName , $ headers ) ) { $ this -> contextDataExists = true ; $ this -> contextDataValue = $ headers [ $ paramName ] ; } return $ this -> checkDataIsEmpty ( ) ; }
Filtering the response header load the data and check it
5,253
public function loadRequestBody ( ) { if ( array_key_exists ( 'php://input' , $ this -> mockedData ) ) { $ this -> loadBodyByContent ( $ this -> getRequestHeader ( ) , $ this -> mockedData [ 'php://input' ] ) ; } else { $ this -> loadBodyByContent ( $ this -> getRequestHeader ( ) , file_get_contents ( "php://input" ) )...
Method to load Request body identify by his content type header And only if a content length is defined and > 0
5,254
public function loadResponseBody ( ) { if ( array_key_exists ( 'php://output' , $ this -> mockedData ) ) { $ this -> loadBodyByContent ( $ this -> getResponseHeader ( ) , $ this -> mockedData [ 'php://output' ] ) ; } else { $ this -> loadBodyByContent ( $ this -> getResponseHeader ( ) , file_get_contents ( "php://outpu...
Method to load Response body identify by his content type header And only if a content length is defined and > 0
5,255
public function buildBodyJson ( $ contents ) { $ this -> contextDataType = self :: CONTENT_TYPE_JSON ; $ this -> contextDataExists = ( bool ) ( strlen ( $ contents ) > 0 ) ; $ this -> contextDataValue = json_decode ( $ contents , false ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { $ this -> contextDataEmpty = tr...
Method to build the body mixed data from a JSON Raw Body
5,256
public function buildBodyXml ( $ contents ) { $ this -> contextDataType = self :: CONTENT_TYPE_XML ; $ this -> contextDataExists = ( bool ) ( strlen ( $ contents ) > 0 ) ; $ this -> contextDataValue = simplexml_load_string ( $ contents ) ; if ( $ this -> contextDataValue === false ) { $ this -> contextDataEmpty = true ...
Method to build the body mixed data from a XML Raw Body
5,257
public function setSandBox ( ) { if ( $ this -> getType ( ) !== self :: TYPE_REQUEST ) { return $ this ; } $ last = $ this -> getLastDataPath ( ) ; $ last = array_pop ( $ last ) ; switch ( $ this -> getLocation ( ) ) { case \ SwaggerValidator \ Common \ FactorySwagger :: LOCATION_BODY : \ SwaggerValidator \ Common \ Sa...
Adding validated params to check This method improve the TOOMANY errors at the end of the validation process
5,258
public function getRequestDataKeys ( ) { if ( $ this -> getType ( ) !== self :: TYPE_REQUEST ) { return array ( ) ; } if ( array_key_exists ( 'php://input' , $ this -> mockedData ) ) { $ data = $ this -> mockedData [ 'php://input' ] ; } else { $ data = file_get_contents ( "php://input" ) ; } return array ( \ SwaggerVal...
Method to list all received params name by location
5,259
public function getEnv ( $ name ) { if ( array_key_exists ( $ name , $ this -> mockedData ) ) { return $ this -> mockedData [ $ name ] ; } return getenv ( $ name ) ; }
Method to add capability of override the getenv function of PHP for example to get env data in a sandbox
5,260
public function mock ( $ options = array ( ) ) { $ this -> mockedData = $ options ; if ( empty ( $ this -> mockedData ) || ! is_array ( $ this -> mockedData ) ) { $ this -> mockedData = array ( ) ; } }
Method to define a batch of data to be used to simulate the playback of external data
5,261
public function cleanParams ( ) { $ _GET = array ( ) ; $ _POST = array ( ) ; $ _FILES = array ( ) ; $ _COOKIE = array ( ) ; foreach ( $ this -> getRequestHeader ( ) as $ key ) { if ( array_key_exists ( $ key , $ _SERVER ) ) { unset ( $ _SERVER [ $ key ] ) ; } } }
Used to clean params if validation error occured for mode PASS
5,262
public function logLoadFile ( $ file , $ method = null , $ line = null ) { if ( self :: getConfig ( 'log' , 'loadFile' ) ) { $ this -> logMessage ( 'LOAD FILE' , 'Loading File : "' . $ file . '"' , $ method , $ line ) ; } }
Log loading file
5,263
public function logDecode ( $ className , $ method = null , $ line = null ) { if ( self :: getConfig ( 'log' , 'decode' ) ) { $ this -> logMessage ( 'DECODE' , 'Decoding Path "' . $ this -> getDataPath ( ) . '" As "' . $ className . '"' , $ method , $ line ) ; } }
Log a decoding json mixed data as SwaggerValidator PHP object
5,264
public function logModel ( $ method = null , $ line = null ) { if ( self :: getConfig ( 'log' , 'model' ) ) { $ this -> logMessage ( 'MODEL' , 'Model Created "' . $ this -> getDataPath ( ) . '"' , $ method , $ line ) ; } }
Log a creation model success
5,265
public function logReference ( $ type , $ ref , $ oldRef = null , $ method = null , $ line = null ) { if ( self :: getConfig ( 'log' , 'reference' ) || self :: getConfig ( 'log' , $ type . 'Ref' ) ) { switch ( $ type ) { case 'replace' : $ this -> logMessage ( 'REPLACE REF' , 'Replacing Reference From "' . $ oldRef . '...
Log an external reference action
5,266
public function logMessage ( $ type , $ message , $ method = null , $ line = null ) { if ( is_array ( $ message ) || is_object ( $ message ) ) { $ message = \ SwaggerValidator \ Common \ Collection :: jsonEncode ( $ message ) ; } print "[" . date ( 'Y-m-d H:i:s' ) . "][{$type}][{{$method}#{$line}] - {$message} \n" ; }
Used to customizing log and more when a debug is send
5,267
public function throwException ( $ message , $ method = null , $ line = null ) { $ this -> logException ( $ message , $ method , $ line ) ; $ e = new \ SwaggerValidator \ Exception ( $ message ) ; $ e -> setFile ( $ method ) ; $ e -> setLine ( $ line ) ; $ e -> setContext ( $ this ) ; throw $ e ; }
Throw a new \ SwaggerValidator \ Exception with automatic find method line ...
5,268
private function prepareTransaction ( AbstractTransactionCommand $ transaction , bool $ force = false ) : void { if ( ! $ force && ( null !== $ transaction -> getLastMsid ( ) ) && ( null !== $ transaction -> getLastHash ( ) ) ) { return ; } $ sender = $ transaction -> getSender ( ) ; if ( null !== $ sender ) { $ resp =...
Fills last account hash and message id in request . Function needs to be called before transaction . Otherwise above parameters should be passed explicitly .
5,269
public function changeAccountKey ( ChangeAccountKeyCommand $ command , bool $ isDryRun = false ) : ChangeAccountKeyResponse { $ this -> prepareTransaction ( $ command ) ; $ response = $ this -> driver -> executeTransaction ( $ command , $ isDryRun ) ; return new ChangeAccountKeyResponse ( $ response -> getRawData ( ) )...
Executes change_account_key transaction .
5,270
public function changeNodeKey ( ChangeNodeKeyCommand $ command , bool $ isDryRun = false ) : ChangeNodeKeyResponse { $ this -> prepareTransaction ( $ command ) ; $ response = $ this -> driver -> executeTransaction ( $ command , $ isDryRun ) ; return new ChangeNodeKeyResponse ( $ response -> getRawData ( ) ) ; }
Executes change_node_key transaction .
5,271
public function createAccount ( CreateAccountCommand $ command , bool $ isDryRun = false ) : CreateAccountResponse { $ this -> prepareTransaction ( $ command ) ; $ response = $ this -> driver -> executeTransaction ( $ command , $ isDryRun ) ; return new CreateAccountResponse ( $ response -> getRawData ( ) ) ; }
Executes create_account transaction .
5,272
public function getAccount ( string $ address ) : GetAccountResponse { $ command = new GetAccountCommand ( $ address ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetAccountResponse ( $ response -> getRawData ( ) ) ; }
Returns account data .
5,273
public function getAccounts ( string $ nodeId , ? string $ blockId = null ) : GetAccountsResponse { $ node = hexdec ( $ nodeId ) ; $ command = new GetAccountsCommand ( $ node , $ blockId ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetAccountsResponse ( $ response -> getRawData ( ) ) ;...
Returns account list for node .
5,274
public function getBlock ( ? string $ blockId = null ) : GetBlockResponse { $ command = new GetBlockCommand ( $ blockId ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetBlockResponse ( $ response -> getRawData ( ) ) ; }
Returns block data .
5,275
public function getBlockIds ( ? string $ blockIdFrom = null , ? string $ blockIdTo = null ) : GetBlockIdsResponse { $ command = new GetBlockIdsCommand ( $ blockIdFrom , $ blockIdTo ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetBlockIdsResponse ( $ response -> getRawData ( ) ) ; }
Updates block data for selected period and returns ids of updated blocks .
5,276
public function getBroadcast ( ? string $ blockId = null ) : GetBroadcastResponse { $ command = new GetBroadcastCommand ( $ blockId ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetBroadcastResponse ( $ response -> getRawData ( ) ) ; }
Collects broadcast messages for particular block . Messages are in random order and can be duplicated .
5,277
public function getLog ( ? \ DateTime $ from = null ) : GetLogResponse { $ command = new GetLogCommand ( $ from ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetLogResponse ( $ response -> getRawData ( ) ) ; }
Returns available log event .
5,278
public function getMe ( ) : GetAccountResponse { $ command = new GetMeCommand ( ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetAccountResponse ( $ response -> getRawData ( ) ) ; }
Returns current account data . Current account is the account which was used to initialize AdsClient .
5,279
public function getMessage ( string $ messageId , ? string $ blockId = null ) : GetMessageResponse { $ command = new GetMessageCommand ( $ messageId , $ blockId ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetMessageResponse ( $ response -> getRawData ( ) ) ; }
Returns message data . Each message contains one or more transactions .
5,280
public function getMessageIds ( ? string $ blockId = null ) : GetMessageIdsResponse { $ command = new GetMessageIdsCommand ( $ blockId ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetMessageIdsResponse ( $ response -> getRawData ( ) ) ; }
Returns message ids for selected block .
5,281
public function getTransaction ( string $ txid ) : GetTransactionResponse { $ command = new GetTransactionCommand ( $ txid ) ; $ response = $ this -> driver -> executeCommand ( $ command ) ; return new GetTransactionResponse ( $ response -> getRawData ( ) ) ; }
Returns single transaction data .
5,282
final public static function autoload ( $ className ) { if ( \ Phar :: running ( ) && defined ( 'PHAR_SWAGGER_VALIDATOR_ROOT_PATH' ) ) { $ baseDir = PHAR_SWAGGER_VALIDATOR_ROOT_PATH ; } elseif ( \ Phar :: running ( ) ) { $ baseDir = null ; } else { $ baseDir = __DIR__ . DIRECTORY_SEPARATOR ; } $ thisClass = 'SwaggerVal...
Slim PSR - 0 autoloader
5,283
private static function crc16 ( string $ hexChars ) : int { $ chars = hex2bin ( $ hexChars ) ; if ( $ chars ) { $ crc = 0x1D0F ; for ( $ i = 0 ; $ i < strlen ( $ chars ) ; $ i ++ ) { $ x = ( $ crc >> 8 ) ^ ord ( $ chars [ $ i ] ) ; $ x ^= $ x >> 4 ; $ crc = ( ( $ crc << 8 ) ^ ( $ x << 12 ) ^ ( $ x << 5 ) ^ ( $ x ) ) & ...
Generates CRC16 checksum .
5,284
public static function getAccountChecksum ( int $ node , int $ user ) : string { return sprintf ( '%04X' , self :: crc16 ( sprintf ( '%04X%08X' , $ node , $ user ) ) ) ; }
Generate checksum for account .
5,285
public function getSiblings ( $ andSelf = false ) { $ tableName = $ this -> owner -> tableName ( ) ; $ path = $ this -> getParentPath ( ) ; $ like = strtr ( $ path . $ this -> delimiter , [ '%' => '\%' , '_' => '\_' , '\\' => '\\\\' ] ) ; $ query = $ this -> owner -> find ( ) -> andWhere ( [ 'like' , "{$tableName}.[[{$...
Returns all sibilings of node .
5,286
private function getClass ( $ type ) { $ collType = \ SwaggerValidator \ Common \ CollectionType :: getInstance ( ) ; $ class = $ collType -> get ( $ type ) ; if ( empty ( $ class ) ) { $ e = new \ SwaggerValidator \ Exception ( 'Cannot retrieve the callable for this type : ' . $ type ) ; $ e -> setFile ( __METHOD__ ) ...
Check if the type is defined and return his callable string
5,287
public function invoke ( $ type , $ parameters = null ) { $ class = $ this -> getClass ( $ type ) ; $ name = $ this -> normalizeType ( $ type ) ; $ params = func_get_args ( ) ; array_shift ( $ params ) ; $ reflector = new \ ReflectionClass ( $ class ) ; $ instance = $ reflector -> newInstanceArgs ( $ params ) ; if ( em...
Start new instance of the object type
5,288
public function registerClosure ( $ type , $ object ) { $ class = $ this -> getClass ( $ type ) ; $ name = $ this -> normalizeType ( $ type ) ; if ( is_object ( $ object ) || ( $ object instanceof \ Closure ) ) { parent :: __set ( $ name , $ object ) ; return true ; } return false ; }
Register the base instance to be clone when a new instance is call
5,289
public static function setCachePath ( $ pathCacheFile ) { self :: $ cacheEnable = false ; if ( ! empty ( $ pathCacheFile ) && file_exists ( $ pathCacheFile ) ) { self :: $ cacheEnable = true ; self :: $ cachePath = $ pathCacheFile ; } elseif ( ! empty ( $ pathCacheFile ) && ! file_exists ( dirname ( $ pathCacheFile ) )...
Store the cache path and check if the file cache can enabled or not
5,290
public static function load ( \ SwaggerValidator \ Common \ Context $ context ) { if ( self :: $ cacheEnable !== true || ! file_exists ( self :: $ cachePath ) ) { return self :: regenSwagger ( $ context ) ; } if ( ( filemtime ( self :: $ cachePath ) + self :: $ cacheLifeTime ) < time ( ) && self :: $ cacheLifeTime > 0 ...
Load the Swagger Object from the cache file or create a new
5,291
protected static function regenSwagger ( \ SwaggerValidator \ Common \ Context $ context ) { $ fileObj = \ SwaggerValidator \ Common \ CollectionFile :: getInstance ( ) -> get ( $ context , self :: $ swaggerFile ) ; if ( ! is_object ( $ fileObj ) && ( $ fileObj instanceof \ SwaggerValidator \ Common \ ReferenceFile ) )...
Return a Swagger Object new object
5,292
protected static function loadCache ( \ SwaggerValidator \ Common \ Context $ context ) { self :: cleanInstances ( ) ; $ swagger = include self :: $ cachePath ; if ( ! is_array ( $ swagger ) ) { $ context -> throwException ( 'Cannot Load Cache file : ' . self :: $ cachePath , __METHOD__ , __LINE__ ) ; } $ swagger = $ s...
load cache file or call regen file cache
5,293
protected static function storeCache ( \ SwaggerValidator \ Object \ Swagger $ swagger , \ SwaggerValidator \ Common \ Context $ context ) { if ( self :: $ cacheEnable !== true ) { return $ swagger ; } if ( ! file_exists ( self :: $ cachePath ) && ! touch ( self :: $ cachePath ) ) { self :: $ cacheEnable = false ; $ co...
store the new swagger object is available
5,294
public function renderDataCell ( $ model , $ key , $ index ) { if ( is_callable ( $ this -> value ) ) { $ value = call_user_func ( $ this -> value , $ model , $ key , $ index ) ; } else { $ value = $ this -> value ; } if ( $ this -> format !== null ) { $ value = Yii :: $ app -> getFormatter ( ) -> format ( $ value , $ ...
Render data cell
5,295
public static function adsToClicks ( $ amount ) : int { $ amountAsString = ( string ) $ amount ; if ( strpos ( $ amountAsString , '.' ) !== false ) { $ ar = explode ( '.' , $ amountAsString ) ; $ ar [ 1 ] = str_pad ( $ ar [ 1 ] , 11 , '0' ) ; $ amountAsString = implode ( $ ar ) ; } else { $ amountAsString = $ amountAsS...
Converts Ads to clicks .
5,296
public static function clicksToAds ( $ amount ) : string { $ amountAsString = ( string ) $ amount ; $ isNegativeValue = false ; if ( '-' === $ amountAsString [ 0 ] ) { $ isNegativeValue = true ; $ amountAsString = substr ( $ amountAsString , 1 , strlen ( $ amountAsString ) ) ; } $ amountAsString = str_pad ( $ amountAsS...
Converts clicks to Ads .
5,297
protected function getActions ( $ controller ) { $ actions = array_keys ( $ controller -> actions ( ) ) ; $ class = new \ ReflectionClass ( $ controller ) ; foreach ( $ class -> getMethods ( ) as $ method ) { $ name = $ method -> getName ( ) ; if ( $ name !== 'actions' && $ method -> isPublic ( ) && ! $ method -> isSta...
Returns all available actions of the specified controller .
5,298
private static function getProperty ( Prophet $ prophet , $ property ) { $ reflection = new \ ReflectionProperty ( $ prophet , $ property ) ; $ reflection -> setAccessible ( true ) ; return $ reflection -> getValue ( $ prophet ) ; }
Returns a private property of a prophet .
5,299
public function registerCallable ( \ SwaggerValidator \ Common \ Context $ context , $ type , $ callable ) { if ( ! $ this -> __isset ( $ type ) ) { $ context -> throwException ( 'Cannot find type : "' . $ type . '" (Normalized : "' . $ this -> normalizeType ( $ type ) . '" ' , __FILE__ , __LINE__ ) ; } if ( is_callabl...
Replace the default callable string by the given for the type in parameters