idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
17,500
public function setUseSession ( $ useSession ) { $ this -> useSession = ( bool ) $ useSession ; if ( $ useSession ) { SessionHandler :: enable ( ) ; } else { SessionHandler :: disable ( ) ; } return $ this ; }
Enable or disable Session handeling in cache files
17,501
private function currentMobile ( ) { if ( ! $ this -> MobileDetect || ! ( $ this -> MobileDetect instanceof \ Mobile_Detect ) ) { return false ; } return $ this -> MobileDetect -> isMobile ( ) && ! $ this -> MobileDetect -> isTablet ( ) ; }
Whether current page was accessed from a mobile phone
17,502
public function isSuccessful ( ) { if ( ( string ) $ this -> data -> Status -> statusCode !== '000' || ( $ this -> hasTransaction ( ) && ( string ) $ this -> data -> Payment -> TxnList -> Txn -> approved !== 'Yes' ) ) { return false ; } return true ; }
Determine if the transaction is successful or not .
17,503
public function getMessageId ( ) { $ messageId = $ this -> getParameter ( 'messageId' ) ; if ( empty ( $ messageId ) ) { $ this -> setMessageId ( substr ( md5 ( microtime ( ) ) , 0 , 30 ) ) ; } return $ this -> getParameter ( 'messageId' ) ; }
Get the messageID for the request .
17,504
protected function getBaseXML ( ) { foreach ( $ this -> requiredFields as $ field ) { $ this -> validate ( $ field ) ; } $ xml = new \ SimpleXMLElement ( '<SecurePayMessage/>' ) ; $ messageInfo = $ xml -> addChild ( 'MessageInfo' ) ; $ messageInfo -> messageID = $ this -> getMessageId ( ) ; $ messageInfo -> addChild ( ...
XML Template of a SecurePayMessage .
17,505
protected function getBasePaymentXML ( ) { $ xml = $ this -> getBaseXML ( ) ; $ payment = $ xml -> addChild ( 'Payment' ) ; $ txnList = $ payment -> addChild ( 'TxnList' ) ; $ txnList -> addAttribute ( 'count' , 1 ) ; $ transaction = $ txnList -> addChild ( 'Txn' ) ; $ transaction -> addAttribute ( 'ID' , 1 ) ; $ trans...
XML template of a SecurePayMessage Payment .
17,506
public function loadStatus ( $ serviceName , $ attributeName ) { $ this -> loadStatsArray ( ) ; if ( isset ( $ this -> stats [ $ serviceName ] [ $ attributeName ] ) ) { return $ this -> stats [ $ serviceName ] [ $ attributeName ] ; } else { return "" ; } }
Loads circuit breaker service status values from array . Only one remote call for all services .
17,507
public function saveStatus ( $ serviceName , $ attributeName , $ value , $ flush = false ) { $ this -> loadStatsArray ( ) ; $ this -> dirtyStats [ $ serviceName ] [ $ attributeName ] = $ value ; $ this -> stats [ $ serviceName ] [ $ attributeName ] = $ value ; if ( $ flush ) { $ this -> stats = false ; $ this -> loadSt...
We reload values just before saving to reduce race condition time . The updated values are merged with previous values . Then everything is stored back into the storage
17,508
protected function loadStatsArray ( ) { if ( ! is_array ( $ this -> stats ) ) { $ stats = $ this -> instance -> loadStatus ( $ this -> cacheKeyPrefix , $ this -> cacheKeySuffix ) ; if ( ! empty ( $ stats ) ) { $ this -> stats = unserialize ( $ stats ) ; } if ( ! is_array ( $ this -> stats ) ) { $ this -> stats = array ...
Method that actually loads the stats array from wrapped instance . Loads stats only if need to be loaded .
17,509
protected function saveStatsArray ( ) { if ( is_array ( $ this -> stats ) ) { $ this -> instance -> saveStatus ( $ this -> cacheKeyPrefix , $ this -> cacheKeySuffix , serialize ( $ this -> stats ) , true ) ; } }
Method that actually saves the stats array in wrapped instance . Saves only if there is dirty service data .
17,510
protected function load ( $ key ) { try { return $ this -> memcached -> get ( $ key ) ; } catch ( \ Exception $ e ) { throw new StorageException ( "Failed to load memcached key: $key" , 1 , $ e ) ; } }
Loads item by cache key .
17,511
private function login ( ServerRequestInterface $ request ) { $ authorization = $ this -> parseHeader ( $ request -> getHeaderLine ( 'Authorization' ) ) ; if ( ! $ authorization ) { return false ; } if ( ! isset ( $ this -> users [ $ authorization [ 'username' ] ] ) ) { return false ; } if ( $ this -> users [ $ authori...
Check the user credentials and return the username or false .
17,512
public function loadStatus ( $ serviceName , $ attributeName ) { if ( isset ( $ this -> data [ $ serviceName ] [ $ attributeName ] ) ) { return $ this -> data [ $ serviceName ] [ $ attributeName ] ; } return "" ; }
Loads circuit breaker service status value .
17,513
public function saveStatus ( $ serviceName , $ attributeName , $ value , $ flush = false ) { $ this -> data [ $ serviceName ] [ $ attributeName ] = $ value ; }
Saves circuit breaker service status value .
17,514
public static function getMemcachedInstance ( \ Memcached $ memcached , $ maxFailures = 20 , $ retryTimeout = 30 ) { $ storage = new ArrayDecorator ( new MemcachedAdapter ( $ memcached ) ) ; return new CircuitBreaker ( $ storage , $ maxFailures , $ retryTimeout ) ; }
Creates a circuit breaker with same settings for all services using memcached instance as a backend
17,515
private function isValid ( array $ authorization , string $ method , string $ password ) : bool { $ validResponse = md5 ( sprintf ( '%s:%s:%s:%s:%s:%s' , md5 ( sprintf ( '%s:%s:%s' , $ authorization [ 'username' ] , $ this -> realm , $ password ) ) , $ authorization [ 'nonce' ] , $ authorization [ 'nc' ] , $ authorizat...
Validates the authorization .
17,516
public function loadStatus ( $ serviceName , $ attributeName ) { $ this -> checkExtension ( ) ; $ stats = $ this -> load ( $ this -> cachePrefix . $ serviceName . $ attributeName ) ; if ( empty ( $ stats ) ) { $ stats = "" ; } return $ stats ; }
Loads circuit breaker service status value . For example failures count or last retry time . Method does not care what are the attribute names . They are not inspected . Any string can be passed as service name and attribute name .
17,517
public function setServiceSettings ( $ serviceName , $ maxFailures , $ retryTimeout ) { $ this -> settings [ $ serviceName ] = array ( 'maxFailures' => $ maxFailures ? $ maxFailures : $ this -> defaultMaxFailures , 'retryTimeout' => $ retryTimeout ? $ retryTimeout : $ this -> defaultRetryTimeout , ) ; return $ this ; }
Use this method only if you want to add server specific threshold and retry timeout .
17,518
private function getSetting ( $ serviceName , $ variable ) { if ( ! isset ( $ this -> settings [ $ serviceName ] ) ) { $ this -> settings [ $ serviceName ] = array ( 'maxFailures' => $ this -> defaultMaxFailures , 'retryTimeout' => $ this -> defaultRetryTimeout , ) ; } return $ this -> settings [ $ serviceName ] [ $ va...
Load setting or initialise service name with defaults for faster lookups
17,519
protected function setAmountsPrecision ( $ array ) { $ amounts = explode ( ',' , str_replace ( ' ' , '' , $ array [ 'amounts' ] ) ) ; unset ( $ array [ 'amounts' ] ) ; $ temp = [ ] ; try { foreach ( $ amounts as $ amount ) { $ temp [ ] = bcadd ( $ amount , '0' , 8 ) ; } return array_merge ( [ 'amounts' => implode ( ','...
Verifying the presicion of the provided amounts . You need to have the php7 . 0 - bcmath package installed .
17,520
public function withdraw ( $ amounts , $ toAddresses , $ nonce = null ) { $ array = [ 'amounts' => $ amounts , 'to_addresses' => $ toAddresses , 'nonce' => $ nonce , ] ; return $ this -> blockIo -> withdraw ( $ this -> setAmountsPrecision ( $ array ) ) ; }
Withdraws amount of coins from any addresses in your account to up to 2500 destination addresses . If you have more than 2500 unarchived addresses on your account you cannot use this method for withdrawal . Please use the more granular withdrawFromAddressesToAddresses or withdrawFromLabelsToLabels methods instead .
17,521
public function getTransactionsByAddresses ( $ type , $ addresses , $ beforeTx = null ) { if ( is_null ( $ beforeTx ) ) { $ array = [ 'type' => $ type , 'addresses' => $ addresses , ] ; } else { $ array = [ 'type' => $ type , 'addresses' => $ addresses , 'before_tx' => $ beforeTx , ] ; } return $ this -> blockIo -> get...
Returns various data for the last 25 transactions spent or received . You can optionally specify a before_tx parameter to get earlier transactions .
17,522
public function getNotConfirmedTxs ( $ toAddress , $ confidenceThreshold ) { $ txs = $ this -> blockIo -> get_transactions ( [ 'addresses' => $ toAddress , 'type' => 'received' ] ) -> data -> txs ; $ txs = array_where ( $ txs , function ( $ value ) use ( $ confidenceThreshold ) { if ( $ value -> confidence < $ confiden...
Look for incoming transactions and know when they have been processed .
17,523
public function createMultiSigAddress ( $ label , $ reqSigs , $ s1 , $ s2 , $ s3 = null , $ s4 = null ) { $ passphrases_array = [ ] ; if ( ! is_null ( $ s4 ) ) { array_push ( $ passphrases_array , $ s4 ) ; } if ( ! is_null ( $ s3 ) ) { array_push ( $ passphrases_array , $ s3 ) ; } if ( ! is_null ( $ s2 ) ) { array_push...
Create a MultiSig address .
17,524
public function multiSigWithdraw ( $ label , $ toAddresses , $ amount ) { $ array = [ 'from_labels' => $ label , 'to_addresses' => $ toAddresses , 'amounts' => $ amount , ] ; $ response = $ this -> blockIo -> withdraw_from_dtrust_address ( $ array ) ; $ reference_id = $ response -> data -> reference_id ; return compact...
Perform a MultiSig withdraw returns the withdraw object and the withdraw reference id for later signing off the withdraw .
17,525
public function signMultiSigWithdraw ( $ reference_id , $ passphrase ) { $ response = $ this -> getMultiSigWithdraw ( $ reference_id ) ; $ key = $ this -> getKey ( $ passphrase ) ; $ signature = & $ key ; foreach ( $ response -> data -> details -> inputs as & $ input ) { $ dataToSign = $ input -> data_to_sign ; foreach...
Sign a MultiSig withdraw .
17,526
public function getCreatedByNameAttribute ( ) { if ( $ this -> { $ this -> getCreatedByColumn ( ) } ) { return $ this -> creator -> first_name . ' ' . $ this -> creator -> last_name ; } return '' ; }
Get created by user full name .
17,527
public function getUpdatedByNameAttribute ( ) { if ( $ this -> { $ this -> getUpdatedByColumn ( ) } ) { return $ this -> updater -> first_name . ' ' . $ this -> updater -> last_name ; } return '' ; }
Get updated by user full name .
17,528
public function match ( Request $ request , $ route = false ) { if ( count ( $ this -> _childs ) ) { $ route = $ this -> _match ( $ request , $ route ) ; } if ( ! $ route ) { $ route = $ this -> _default ( $ request ) -> merge ( $ route ) ; } if ( ! $ route ) { throw new RuntimeException ( "Missing route..." ) ; } retu...
Match a request on a route
17,529
public function creating ( Model $ model ) { if ( ! $ model -> created_by ) { $ model -> created_by = $ this -> getAuthenticatedUserId ( ) ; } if ( ! $ model -> updated_by ) { $ model -> updated_by = $ this -> getAuthenticatedUserId ( ) ; } }
Model s creating event hook .
17,530
public function dispatch ( Route $ route ) { do { $ this -> getEventManager ( ) -> publish ( "pre.dispatch" , array ( $ route , $ this ) ) ; $ protoView = $ this -> _view -> cloneThis ( ) ; $ controllerClassName = $ route -> getControllerName ( ) . "Controller" ; $ action = $ route -> getActionName ( ) . "Action" ; $ c...
dispatch an action
17,531
public function redirect ( $ url , $ header = 301 ) { $ this -> disableLayout ( ) ; $ this -> setNoRender ( ) ; $ this -> _params [ "dispatcher" ] -> clearHeaders ( ) ; $ this -> _params [ "dispatcher" ] -> addHeader ( "Location" , $ url , $ header ) ; }
Using the dispatcher
17,532
protected function convertUrl ( $ url , $ https ) { $ scheme = ( $ https ) ? 'https' : 'http' ; $ parser = new Url ( $ url ) ; $ parser -> setScheme ( $ scheme ) ; return $ parser -> __toString ( ) ; }
Convert URL from HTTP to HTTPS and vice versa .
17,533
public function getTag ( ) { $ piwikUrl = $ this -> getPiwikUrl ( ) ; $ tag = <<<'EOT'<script type="text/javascript">var _paq = _paq || [];(function(){ var u=(("https:" == document.location.protocol) ? "%s/" : "%s/");_paq.push(['setSiteId', %s]);_paq.push(['setTrackerUrl', u+'piwik.php']);_paq.push(['trackPageView']);...
Get javascript tag for use in tracking the website .
17,534
public function merge ( $ parent ) { $ merged = clone $ this ; if ( $ parent ) { ( $ this -> getActionName ( ) ) ? $ merged -> setActionName ( $ this -> getActionName ( ) ) : $ merged -> setActionName ( $ parent -> getActioName ( ) ) ; ( $ this -> getControllerName ( ) ) ? $ merged -> setControllerName ( $ this -> getC...
Merge parent route with this
17,535
public function validate ( MethodInterface $ method ) { $ constraints = $ method -> getValidationConstraints ( ) ; if ( empty ( $ constraints ) ) { return ; } $ violations = $ this -> validator -> validate ( $ method -> getAttributes ( ) , $ constraints ) ; $ countable = is_array ( $ violations ) || $ violations instan...
Validates given method values against its constraints
17,536
public function getErrorsAsString ( ) { $ string = '' ; foreach ( $ this -> getErrors ( ) as $ error ) { $ string .= sprintf ( "%s: %s" , $ error [ 'field' ] , $ error [ 'message' ] ) ; if ( isset ( $ error [ 'rejected' ] ) ) { $ string .= sprintf ( " ('%s' given)" , $ error [ 'rejected' ] ) ; } $ string .= ";\n" ; } r...
Errors in string form
17,537
public static function create ( array $ options = [ ] , $ logger = Client :: LOG_NONE ) { $ oauth = new Oauth1 ( [ 'token_secret' => '' , 'consumer_key' => $ options [ 'consumerKey' ] , 'consumer_secret' => $ options [ 'consumerSecret' ] ] ) ; $ stack = HandlerStack :: create ( ) ; $ stack -> push ( $ oauth ) ; if ( ! ...
Public factory method to create instance of Client .
17,538
public function call ( MethodInterface $ method ) { $ this -> validator -> validate ( $ method ) ; return $ this -> handleRequest ( $ method ) ; }
Call the given method .
17,539
private function getOptions ( MethodInterface $ method ) { if ( $ method -> getMethod ( ) == $ method :: GET ) { return [ 'query' => $ method -> getAttributes ( ) , ] ; } return [ 'headers' => [ 'Content-Type' => 'application/json' , ] , 'body' => json_encode ( $ this -> prepareAttributes ( $ method -> getAttributes ( ...
Prepare request options for particular method
17,540
private function prepareAttributes ( array $ data ) { foreach ( $ data as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ data [ $ key ] = $ this -> prepareAttributes ( $ value ) ; continue ; } if ( is_float ( $ value ) ) { $ value = sprintf ( "%01.2f" , $ value ) ; } } return $ data ; }
Prepare request attributes
17,541
public function parse ( $ docblock ) { $ docblock = $ this -> getDocblockTagsSection ( $ docblock ) ; $ annotations = $ this -> parseAnnotations ( $ docblock ) ; foreach ( $ annotations as & $ value ) { if ( 1 == count ( $ value ) ) { $ value = $ value [ 0 ] ; } } return $ annotations ; }
Parse a given docblock
17,542
protected function getDocblockTagsSection ( $ docblock ) { $ docblock = $ this -> sanitizeDocblock ( $ docblock ) ; preg_match ( '/^\s*\\' . self :: TOKEN_ANNOTATION_IDENTIFIER . '/m' , $ docblock , $ matches , PREG_OFFSET_CAPTURE ) ; return isset ( $ matches [ 0 ] ) ? substr ( $ docblock , $ matches [ 0 ] [ 1 ] ) : ''...
Filters docblock tags section removing unwanted long and short descriptions
17,543
public function get ( $ key , $ defaut = null ) { if ( $ this -> has ( $ key ) ) { return $ this -> attributes [ $ key ] ; } return $ defaut ; }
Retrieves a single annotation value
17,544
public function getAsArray ( $ key ) { if ( ! $ this -> has ( $ key ) ) { return [ ] ; } $ res = $ this -> attributes [ $ key ] ; if ( is_null ( $ res ) ) { return [ null ] ; } return ( array ) $ res ; }
Retrieve annotation values as an array even if there s only one single value
17,545
public function grep ( $ pattern ) { $ results = array_intersect_key ( $ this -> attributes , array_flip ( RegexGuard :: getGuard ( ) -> grep ( $ pattern , array_keys ( $ this -> attributes ) ) ) ) ; return new static ( $ results ) ; }
Filters annotations based on a regexp
17,546
public function useNamespace ( $ pattern , array $ delimiters = [ '.' , '\\' ] ) { $ mask = implode ( '' , $ delimiters ) ; $ consumer = '(' . implode ( '|' , array_map ( 'preg_quote' , $ delimiters ) ) . ')' ; $ namespace_pattern = '/^' . preg_quote ( rtrim ( $ pattern , $ mask ) ) . $ consumer . '/' ; $ iterator = ne...
Isolates a given namespace of annotations .
17,547
public function parse ( $ value , $ class = null ) { if ( ! class_exists ( $ class ) ) { throw new ParserException ( "Concrete annotation expects {$class} to exist." ) ; } $ prototype = ( new JsonType ) -> parse ( $ value ) ; if ( $ prototype instanceof stdClass ) { if ( ! $ this -> isPrototypeSchemaValid ( $ prototype...
Process a value to be a concrete annotation
17,548
protected function makeInstance ( $ class , stdClass $ prototype ) { $ reflection = new ReflectionClass ( $ class ) ; if ( isset ( $ prototype -> __construct ) ) { $ instance = $ reflection -> newInstanceArgs ( $ prototype -> __construct ) ; unset ( $ prototype -> __construct ) ; } else { $ instance = $ reflection -> n...
Creates and hydrates a concrete annotation class
17,549
protected function doMethodConfiguration ( $ instance , stdClass $ prototype ) { foreach ( $ prototype as $ method => $ args ) { call_user_func_array ( [ $ instance , $ method ] , $ args ) ; } return $ instance ; }
Do configuration injection through method calls
17,550
protected function isPrototypeSchemaValid ( stdclass $ prototype ) { foreach ( $ prototype as $ method => $ args ) { if ( ! is_array ( $ args ) ) { return false ; } } return true ; }
Validates a prototype object
17,551
public function get ( ClientException $ exception , MethodInterface $ method ) { $ map = $ this -> getMap ( ) ; if ( $ this -> supports ( $ exception , $ map ) ) { return $ this -> create ( $ this -> getMappedClass ( $ exception , $ map ) , $ exception , $ method ) ; } return $ this -> create ( 'Cardinity\\Exception\\U...
Get mapped exception
17,552
private function getSetterName ( $ field ) { $ parts = explode ( '_' , $ field ) ; array_map ( 'ucfirst' , $ parts ) ; $ name = 'set' . implode ( '' , $ parts ) ; return $ name ; }
Extracts camelCased setter name from underscore notation . Eg . my_field_name = > myFieldName
17,553
private function transformPaymentInstrumentValue ( array $ data , $ method ) { if ( $ method == 'card' ) { $ instrument = new PaymentInstrumentCard ( ) ; } elseif ( $ method == 'recurring' ) { $ instrument = new PaymentInstrumentRecurring ( ) ; } else { throw new Exception \ Runtime ( sprintf ( 'Method "%s" is not supp...
Transform PaymentInstrument result array to object
17,554
public function parse ( $ value , $ annotation = null ) { if ( '' === $ value ) return true ; $ json = JsonType :: jsonDecode ( $ value ) ; if ( JSON_ERROR_NONE === json_last_error ( ) ) { return $ json ; } elseif ( false !== ( $ int = filter_var ( $ value , FILTER_VALIDATE_INT ) ) ) { return $ int ; } elseif ( false !...
Parse a given undefined type value
17,555
public function parse ( $ value , $ annotation = null ) { if ( false === ( $ value = filter_var ( $ value , FILTER_VALIDATE_INT ) ) ) { throw new ParserException ( "Raw value must be integer. Invalid value '{$value}' given." ) ; } return $ value ; }
Filter a value to be an Integer
17,556
public function parse ( $ value , $ annotation = null ) { if ( false === ( $ value = filter_var ( $ value , FILTER_VALIDATE_FLOAT ) ) ) { throw new ParserException ( "Raw value must be float. Invalid value '{$value}' given." ) ; } return $ value ; }
Filter a value to be a Float
17,557
public function serialize ( $ toJson = true ) { $ data = [ ] ; $ getters = $ this -> classGetters ( get_class ( $ this ) ) ; foreach ( $ getters as $ method ) { $ property = $ this -> propertyName ( $ method ) ; $ value = $ this -> $ method ( ) ; if ( is_float ( $ value ) ) { $ value = sprintf ( "%01.2f" , $ value ) ; ...
Serializes result object to json object
17,558
public function unserialize ( $ string ) { $ data = json_decode ( $ string ) ; foreach ( $ data as $ property => $ value ) { $ method = $ this -> setterName ( $ property ) ; if ( is_numeric ( $ value ) && strstr ( $ value , '.' ) ) { $ value = floatval ( $ value ) ; } elseif ( is_object ( $ value ) ) { if ( $ property ...
Loads result object values from json object
17,559
public function parse ( $ value , $ annotation = null ) { $ json = static :: jsonDecode ( $ value ) ; if ( JSON_ERROR_NONE != json_last_error ( ) ) { throw new ParserException ( "Raw value must be a valid JSON string. Invalid value '{$value}' given." ) ; } return $ json ; }
Filter a value to be a Json
17,560
public static function jsonDecode ( $ value ) { if ( defined ( 'JSON_PARSER_NOTSTRICT' ) ) { $ decoded = json_decode ( $ value , false , 512 , JSON_PARSER_NOTSTRICT ) ; } else { $ decoded = json_decode ( $ value ) ; } return $ decoded ; }
Wrapper fo json_decode function that keeps parser portable between json - ext and pecl - json - c extensions
17,561
protected function parseValue ( $ value , $ key = null ) { $ value = trim ( $ value ) ; $ type = '\Minime\\Annotations\\Types\\DynamicType' ; if ( preg_match ( $ this -> typesPattern , $ value , $ found ) ) { $ type = $ found [ 1 ] ; $ value = trim ( substr ( $ value , strlen ( $ type ) ) ) ; if ( in_array ( $ type , $...
Parse a single annotation value
17,562
protected function encrypt ( $ data ) { $ salt = random_bytes ( 16 ) ; $ salted = hash ( 'sha512' , $ this -> key . $ salt , true ) ; $ key = substr ( $ salted , 0 , 32 ) ; $ iv = substr ( $ salted , 32 , 16 ) ; $ encryptedData = openssl_encrypt ( $ data , 'AES-256-CBC' , $ key , OPENSSL_RAW_DATA , $ iv ) ; return base...
Encrypt session data
17,563
protected function decrypt ( $ data ) { $ data = base64_decode ( $ data ) ; $ salt = substr ( $ data , 0 , 16 ) ; $ data = substr ( $ data , 16 ) ; $ salted = hash ( 'sha512' , $ this -> key . $ salt , true ) ; $ key = substr ( $ salted , 0 , 32 ) ; $ iv = substr ( $ salted , 32 , 16 ) ; return openssl_decrypt ( $ data...
Decrypt session data
17,564
final public function assignObjectData ( array $ objectData = [ ] , $ requireAnalysis = false ) { $ this -> _objectData = $ objectData ; if ( $ requireAnalysis ) { $ analysis = $ this -> exportClassAnalysis ( ) ; if ( $ analysis -> hasProblems ( ) ) { throw new LazyJsonMapperException ( $ analysis -> generateNiceSummar...
Assign a new internal JSON data array for this object .
17,565
final public function exportObjectDataCopy ( $ objectRepresentation = 'array' ) { if ( ! in_array ( $ objectRepresentation , [ 'stdClass' , 'array' ] , true ) ) { throw new LazyJsonMapperException ( sprintf ( 'Invalid object representation type "%s". Must be either "stdClass" or "array".' , $ objectRepresentation ) ) ;...
Get a processed copy of this object instance s internal data contents .
17,566
final public function asJson ( $ options = 0 , $ depth = 512 ) { if ( ! is_int ( $ options ) || ! is_int ( $ depth ) ) { throw new LazyJsonMapperException ( 'Invalid non-integer function argument.' ) ; } $ objectData = $ this -> exportObjectDataCopy ( 'stdClass' ) ; $ jsonString = @ json_encode ( $ objectData , $ optio...
Get a processed representation of this object instance s data as JSON .
17,567
final public function printJson ( $ prettyPrint = true , $ depth = 512 ) { $ options = ( $ prettyPrint ? JSON_PRETTY_PRINT : 0 ) | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ; $ json = $ this -> asJson ( $ options , $ depth ) ; if ( $ prettyPrint && PHP_EOL !== "\n" ) { $ json = str_replace ( "\n" , PHP_EOL , $ js...
Print a processed representation of this object instance s data as JSON .
17,568
final public function exportClassAnalysis ( $ recursiveScan = true ) { $ result = new ClassAnalysis ( ) ; $ definitionSource = get_class ( $ this ) ; foreach ( $ this -> _objectData as $ propName => $ value ) { $ propDef = $ this -> _getPropertyDefinition ( $ propName ) ; try { $ value = $ this -> _getProperty ( $ prop...
Analyze the entire object and check for undefined or bad JSON properties .
17,569
final protected function _hasPropertyDefinitionOrData ( $ propName ) { return isset ( $ this -> _compiledPropertyMapLink [ $ propName ] ) || array_key_exists ( $ propName , $ this -> _objectData ) ; }
Check if a property definition or an object instance data value exists .
17,570
final protected function _getPropertyDefinition ( $ propName , $ allowUndefined = true ) { if ( isset ( $ this -> _compiledPropertyMapLink [ $ propName ] ) ) { return $ this -> _compiledPropertyMapLink [ $ propName ] ; } elseif ( $ allowUndefined && array_key_exists ( $ propName , $ this -> _objectData ) ) { return Und...
Get the property definition for an object data property .
17,571
final protected function & _getProperty ( $ propName , $ createMissingValue = false ) { $ propDef = $ this -> _getPropertyDefinition ( $ propName ) ; if ( array_key_exists ( $ propName , $ this -> _objectData ) ) { $ value = & $ this -> _objectData [ $ propName ] ; } elseif ( $ createMissingValue ) { $ this -> _objectD...
Get the value of an object data property .
17,572
final protected function _isProperty ( $ propName ) { return array_key_exists ( $ propName , $ this -> _objectData ) && ( bool ) $ this -> _objectData [ $ propName ] ; }
Check if an object data property exists and its value evaluates to TRUE .
17,573
final protected function _setProperty ( $ propName , $ value ) { $ propDef = $ this -> _getPropertyDefinition ( $ propName ) ; ValueConverter :: convert ( ValueConverter :: CONVERT_TO_INTERNAL , $ value , $ propDef -> arrayDepth , $ propName , $ propDef ) ; $ this -> _objectData [ $ propName ] = $ value ; return $ this...
Set an object data property to a new value .
17,574
final public function serialize ( ) { $ objectData = $ this -> _objectData ; array_walk_recursive ( $ objectData , function ( & $ value ) { if ( is_object ( $ value ) && $ value instanceof self ) { $ value = $ value -> serialize ( $ value ) ; } } ) ; $ args = func_get_args ( ) ; $ isRootObject = ! isset ( $ args [ 0 ] ...
Called during serialization of the object .
17,575
final public function unserialize ( $ serialized = null ) { $ objectData = null ; try { $ objectData = unserialize ( $ serialized ) ; } catch ( \ Exception $ e ) { throw new LazySerializationException ( sprintf ( 'Unexpected exception encountered while unserializing a sub-object. Error: %s' , $ e -> getMessage ( ) ) ) ...
Called during unserialization of the object .
17,576
protected function _propToFunctionCase ( $ propName ) { $ result = ltrim ( $ propName , '_' ) ; $ leadingUnderscores = strlen ( $ propName ) - strlen ( $ result ) ; $ result = preg_replace_callback ( '/(?:^|_)([a-z])/' , function ( $ matches ) { return ucfirst ( $ matches [ 1 ] ) ; } , $ result ) ; if ( $ leadingUnders...
Converts a property name to FunctionCase .
17,577
public static function encodeOperators ( $ str ) { if ( self :: $ _translations === null ) { self :: _buildTranslations ( ) ; } return strtr ( $ str , self :: $ _translations [ 'encode' ] ) ; }
Encode special operators .
17,578
public static function decodeOperators ( $ str ) { if ( self :: $ _translations === null ) { self :: _buildTranslations ( ) ; } return strtr ( $ str , self :: $ _translations [ 'decode' ] ) ; }
Decode special operators .
17,579
private static function _buildTranslations ( ) { $ operators = [ '$' , ',' , ';' , '`' , '=' , '[' , ']' , '(' , ')' , '{' , '}' , '.' , '~' , '@' , '?' , ':' , ' ' , "\t" , '\\' , '#' , "'" , '"' , '+' , '-' , '*' , '/' , '%' , '&' , '|' , '^' , '!' , '<' , '>' , ] ; $ translations = [ 'encode' => [ ] , 'decode' => [ ...
Build the table of special operator translations .
17,580
public static function createStrictClassPath ( $ className = '' ) { if ( is_string ( $ className ) && strlen ( $ className ) > 0 ) { if ( $ className [ 0 ] !== '\\' ) { $ className = '\\' . $ className ; } return $ className ; } return null ; }
Create a strict global class path .
17,581
public static function splitStrictClassPath ( $ strictClassPath = '' ) { $ lastDelimPos = strrpos ( $ strictClassPath , '\\' ) ; $ namespace = substr ( $ strictClassPath , 0 , $ lastDelimPos ) ; $ class = substr ( $ strictClassPath , $ lastDelimPos + 1 ) ; return [ 'namespace' => $ namespace , 'class' => $ class , ] ; ...
Splits a strict class - path into its namespace and class name components .
17,582
public static function createRelativeClassPath ( array $ sourceComponents , array $ targetComponents ) { $ sourceNs = & $ sourceComponents [ 'namespace' ] ; $ targetNs = & $ targetComponents [ 'namespace' ] ; $ finalType = null ; if ( $ sourceNs !== '' && $ targetNs !== '' ) { $ pos = strpos ( $ targetNs , $ sourceNs )...
Compare two class paths and generate the shortest path between them .
17,583
public static function atomicWrite ( $ filename , $ data , $ atomicSuffix = 'atomictmp' ) { $ filenameTmp = sprintf ( '%s.%s' , $ filename , $ atomicSuffix ) ; $ writeResult = @ file_put_contents ( $ filenameTmp , $ data , LOCK_EX ) ; if ( $ writeResult !== false && $ writeResult === strlen ( $ data ) ) { $ moveResult ...
Atomic filewriter .
17,584
public function asString ( ) { return sprintf ( '%s%s%s' , $ this -> isObjectType ? '\\' : '' , $ this -> propType !== null ? $ this -> propType : 'mixed' , str_repeat ( '[]' , $ this -> arrayDepth ) ) ; }
Get the property definition as its string representation .
17,585
public function setVersion ( $ service_id , $ major , $ intermediate , $ minor ) { $ this -> service_id = $ service_id ; $ this -> major = $ major ; $ this -> intermediate = $ intermediate ; $ this -> minor = $ minor ; }
Sets the API service to be used and the version information .
17,586
public function buildRequest ( $ addReq = null ) { $ this -> request [ 'WebAuthenticationDetail' ] = array ( 'UserCredential' => array ( 'Key' => $ this -> key , 'Password' => $ this -> password ) ) ; $ this -> request [ 'ClientDetail' ] = array ( 'AccountNumber' => $ this -> acct_num , 'MeterNumber' => $ this -> meter...
Builds and returns the basic request array to be sent with each request to the FedEx API . This assumes the setVersion method has already been called by an extended class .
17,587
public function getUserList ( ) { if ( $ this -> _userList === null ) { $ this -> _userList = $ this -> asArray ( ) ; } foreach ( $ this -> _userList as & $ value ) { if ( is_array ( $ value ) ) { $ value = new User ( $ value ) ; } } return $ this -> _userList ; }
Get the list of users .
17,588
public function syncUserList ( ) { if ( $ this -> _userList === null ) { $ this -> getUserList ( ) ; } $ newObjectData = [ ] ; foreach ( $ this -> _userList as $ k => $ v ) { $ newObjectData [ $ k ] = is_object ( $ v ) && $ v instanceof LazyJsonMapper ? $ v -> asArray ( ) : $ v ; } $ this -> assignObjectData ( $ newObj...
Syncs the user list cache with the LazyJsonMapper core storage .
17,589
public function getEmployees ( ) { if ( $ this -> _employees === null ) { $ this -> _employees = $ this -> _getProperty ( 'employees' ) ; } foreach ( $ this -> _employees as & $ value ) { if ( is_array ( $ value ) ) { $ value = new User ( $ value ) ; } } return $ this -> _employees ; }
Get the list of employees .
17,590
public function setEmployees ( array $ employees ) { $ this -> _employees = $ employees ; $ newInnerValue = [ ] ; foreach ( $ this -> _employees as $ k => $ v ) { $ newInnerValue [ $ k ] = is_object ( $ v ) && $ v instanceof LazyJsonMapper ? $ v -> asArray ( ) : $ v ; } $ this -> _setProperty ( 'employees' , $ newInner...
Set the list of employees .
17,591
public function getData ( ) { if ( $ this -> _cache === null ) { $ this -> _cache = $ this -> asArray ( ) ; } if ( $ this -> _type !== null ) { foreach ( $ this -> _cache as & $ value ) { if ( is_array ( $ value ) ) { $ value = new $ this -> _type ( $ value ) ; } } } return $ this -> _cache ; }
Get the data array of this unpredictable container .
17,592
public function setData ( array $ value ) { $ this -> _cache = $ value ; $ newObjectData = [ ] ; foreach ( $ this -> _cache as $ k => $ v ) { $ newObjectData [ $ k ] = is_object ( $ v ) && $ v instanceof LazyJsonMapper ? $ v -> asArray ( ) : $ v ; } $ this -> assignObjectData ( $ newObjectData ) ; return $ this ; }
Set the data array of this unpredictable container .
17,593
public function mergeAnalysis ( ClassAnalysis $ other ) { $ this -> bad_definitions = array_merge_recursive ( $ this -> bad_definitions , $ other -> bad_definitions ) ; $ this -> missing_definitions = array_merge_recursive ( $ this -> missing_definitions , $ other -> missing_definitions ) ; }
Merge another ClassAnalysis object s result into this instance .
17,594
public function addProblem ( $ definitionSource , $ problemType , $ problemMessage ) { if ( ! is_string ( $ definitionSource ) || ! is_string ( $ problemMessage ) ) { throw new LazyJsonMapperException ( 'The definitionSource and problemMessage parameters must be strings.' ) ; } if ( $ problemType !== 'bad_definitions' ...
Adds a problem description to the internal state .
17,595
public function generateNiceSummaries ( ) { $ problemSummaries = [ ] ; if ( ! empty ( $ this -> bad_definitions ) ) { $ strSubChunks = [ ] ; foreach ( $ this -> bad_definitions as $ className => $ messages ) { $ strSubChunks [ ] = sprintf ( '"%s": ([\'%s\'])' , $ className , implode ( '\'], and [\'' , $ messages ) ) ; ...
Generates nicely formatted problem summaries for this class analysis .
17,596
public function setTo ( $ namespace , $ key , $ value = null ) { $ oldNamespace = $ this -> namespace ; $ this -> setNamespace ( $ namespace ) ; $ this -> set ( $ key , $ value ) ; $ this -> setNamespace ( $ oldNamespace ) ; }
Set session value or array of values to specific namespace
17,597
public function addTo ( $ namespace , $ key , $ value = null ) { $ oldNamespace = $ this -> namespace ; $ this -> setNamespace ( $ namespace ) ; $ this -> add ( $ key , $ value ) ; $ this -> setNamespace ( $ oldNamespace ) ; }
Add session value or array of values to specific namespace
17,598
public function getFrom ( $ namespace , $ key = null , $ default = null ) { if ( isset ( $ _SESSION [ $ namespace ] ) ) { $ oldNamespace = $ this -> namespace ; $ this -> setNamespace ( $ namespace ) ; $ result = $ this -> get ( $ key , $ default ) ; $ this -> setNamespace ( $ oldNamespace ) ; return $ result ; } retur...
Get session value from specific namespace
17,599
public function hasIn ( $ namespace , $ key ) { if ( isset ( $ _SESSION [ $ namespace ] ) ) { $ oldNamespace = $ this -> namespace ; $ this -> setNamespace ( $ namespace ) ; $ result = $ this -> has ( $ key ) ; $ this -> setNamespace ( $ oldNamespace ) ; return $ result ; } }
Check if session value is set in specific namespace