idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
59,900
public function pipeForContainer ( $ pipe , $ methodName = '' , ... $ params ) : self { if ( $ pipe instanceof Closure ) { $ this -> pipes [ ] = $ pipe ; return $ this ; } $ pipe = [ $ pipe , $ methodName , $ params , true ] ; $ this -> pipes [ ] = $ pipe ; return $ this ; }
Add stage without middleware interface .
59,901
public function execute ( ) { $ pipeline = array_reduce ( array_reverse ( $ this -> pipes ) , $ this -> carry ( ) , function ( $ passable ) { return $ passable ; } ) ; return $ pipeline ( $ this -> passable ) ; }
Run the pipeline without a final destination callback .
59,902
public function filtrarValor ( $ filtro , $ texto ) { if ( isset ( $ this -> filtros [ $ filtro ] ) ) { $ texto = $ this -> filtros [ $ filtro ] ( $ texto ) ; } return $ texto ; }
Aplica el filtro solicitado al valor .
59,903
public function sign ( array $ data ) { ksort ( $ data ) ; $ queryString = $ this -> buildQueryString ( $ data ) ; $ data [ 'h' ] = base64_encode ( hash_hmac ( 'sha1' , $ queryString , $ this -> clientSecret , true ) ) ; return $ data ; }
Signs an array by calculating a signature and setting it on the h key .
59,904
public function verifySignature ( array $ data ) { $ signedData = array_intersect_key ( $ data , array_flip ( self :: $ validResponseParams ) ) ; ksort ( $ signedData ) ; $ queryString = $ this -> buildQueryString ( $ signedData ) ; $ signature = base64_encode ( hash_hmac ( 'sha1' , $ queryString , $ this -> clientSecr...
Verifies that the signature in the h key matches the expected signature .
59,905
public function request ( ) { $ data = $ this -> prepareData ( ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> apiHost . '/api' ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ result = ...
Run API reauest
59,906
private function prepareData ( ) { $ data = [ ] ; foreach ( get_object_vars ( $ this ) as $ property => $ value ) { if ( in_array ( $ property , [ 'apiHost' , 'debug' ] ) ) { continue ; } if ( $ property == 'format' ) { $ data [ $ value ] = '' ; } elseif ( is_bool ( $ value ) && $ value ) { $ data [ $ property ] = '' ;...
Preparing data before request
59,907
private function checkResult ( $ result ) { if ( $ this -> debug ) { if ( in_array ( $ this -> format , [ self :: FORMAT_JSON , self :: FORMAT_JSONP ] ) ) { $ result = json_decode ( $ result , true ) ; } elseif ( $ this -> format == self :: FORMAT_SERIAL ) { $ result = unserialize ( $ result ) ; } if ( is_array ( $ res...
Check response data
59,908
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ serviceLocator = $ serviceLocator -> getServiceLocator ( ) ; $ config = $ serviceLocator -> get ( 'Config' ) ; $ config = ( isset ( $ config [ 'yima_adminor' ] ) && is_array ( $ config [ 'yima_adminor' ] ) ) ? $ config [ 'yima_adminor' ] : [...
Create the Authentication Service
59,909
protected function _extractQuoteSkuData ( Mage_Sales_Model_Quote $ quote ) { $ skuData = [ ] ; foreach ( $ quote -> getAllVisibleItems ( ) as $ item ) { if ( $ item -> getParentItem ( ) ) { continue ; } $ skuData [ $ item -> getSku ( ) ] = [ 'item_id' => $ item -> getId ( ) , 'managed' => Mage :: helper ( 'radial_core/...
Get sku and qty data for a given quote
59,910
protected function _extractAddressData ( Mage_Customer_Model_Address_Abstract $ address ) { return array ( 'street' => $ address -> getStreet ( ) , 'city' => $ address -> getCity ( ) , 'region_code' => $ address -> getRegionCode ( ) , 'country_id' => $ address -> getCountryId ( ) , 'postcode' => $ address -> getPostcod...
Extract array of address data - street city region code etc . from an address object
59,911
protected function _extractQuoteShippingData ( Mage_Sales_Model_Quote $ quote ) { $ shippingData = array ( ) ; foreach ( $ quote -> getAllShippingAddresses ( ) as $ address ) { $ shippingData [ ] = array ( 'method' => $ address -> getShippingMethod ( ) , 'address' => $ this -> _extractAddressData ( $ address ) , ) ; } ...
Extract shipping data from a quote - the shipping method and address for each shipping address in the quote .
59,912
protected function _extractQuoteBillingData ( Mage_Sales_Model_Quote $ quote ) { $ address = $ quote -> getBillingAddress ( ) ; return $ address ? $ this -> _extractAddressData ( $ address ) : array ( ) ; }
Return array of billing address data if available otherwise an empty array
59,913
protected function _extractQuoteAmounts ( Mage_Sales_Model_Quote $ quote ) { return array_map ( function ( $ address ) { return array ( 'subtotal' => round ( $ address -> getSubtotal ( ) , 4 ) ? : 0.0000 , 'discount' => round ( $ address -> getDiscountAmount ( ) , 4 ) ? : 0.0000 , 'ship_amount' => round ( $ address -> ...
Extract quote amounts from each address .
59,914
protected function _diffQuoteData ( $ oldQuote , $ newQuote ) { if ( empty ( $ oldQuote ) ) { return $ newQuote ; } return $ this -> _diffBilling ( $ oldQuote [ 'billing' ] , $ newQuote [ 'billing' ] ) + $ this -> _diffCoupon ( $ oldQuote [ 'coupon' ] , $ newQuote [ 'coupon' ] ) + $ this -> _diffShipping ( $ oldQuote [...
Diff the new quote to the old quote . May contain keys for billing coupon shipping and skus . For more details on the type of changes detected for each key see the responsible methods for diffing those sets of data .
59,915
protected function _anyItem ( $ items , $ key ) { foreach ( $ items as $ item ) { if ( isset ( $ item [ $ key ] ) && $ item [ $ key ] ) { return true ; } } return false ; }
Check the set of items to have an item with the given key set to a truthy value .
59,916
public function keepOpen ( ) { $ stoppedProperty = new \ ReflectionProperty ( get_parent_class ( $ this ) , 'stopped' ) ; $ stoppedProperty -> setAccessible ( TRUE ) ; $ stoppedProperty -> setValue ( $ this , TRUE ) ; }
Calling this method avoids destructor to send DELETE session request .
59,917
public function getLink ( $ presenterName , $ parameters = array ( ) ) { $ url = new \ Nette \ Http \ UrlScript ( $ this -> context -> parameters [ 'selenium' ] [ 'baseUrl' ] ) ; $ url -> scriptPath = $ url -> path ; $ appRequest = new \ Nette \ Application \ Request ( $ presenterName , 'GET' , Utils :: strToArray ( $ ...
Creates an URL .
59,918
public function getAppRequest ( $ url = NULL ) { $ httpRequest = new \ Nette \ Http \ Request ( $ this -> getUrlScriptForUrl ( $ url ? : $ this -> url ( ) ) ) ; return $ this -> context -> router -> match ( $ httpRequest ) ; }
URL back - routed into application request object .
59,919
public function waitForAlert ( $ timeout = 60 ) { $ result = FALSE ; $ i = 0 ; do { sleep ( 1 ) ; try { $ result = $ this -> alertText ( ) ; } catch ( \ RuntimeException $ e ) { ; } } while ( ++ $ i < $ timeout && $ result === FALSE ) ; return $ result ; }
Wait for javascript alert prompt or confirm dialog .
59,920
public function waitForCondition ( $ jsCondition , $ timeout = 60 ) { $ i = 0 ; do { sleep ( 1 ) ; } while ( ! ( $ result = $ this -> execute ( array ( 'script' => 'return ' . $ jsCondition , 'args' => array ( ) ) ) ) && $ i ++ < $ timeout ) ; return $ result ; }
Wait for fulfilment of some javascript condition .
59,921
public function getActiveElement ( ) { $ response = $ this -> driver -> curl ( 'POST' , $ this -> url -> addCommand ( 'element/active' ) ) ; return Element :: fromResponseValue ( $ response -> getValue ( ) , $ this -> url -> descend ( 'element' ) , $ this -> driver ) ; }
Get the element on the page that currently has focus .
59,922
public function element ( \ PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $ criteria ) { $ value = $ this -> postCommand ( 'element' , $ criteria ) ; return Element :: fromResponseValue ( $ value , $ this -> url -> descend ( 'element' ) , $ this -> driver ) ; }
Finds an element using the criteria .
59,923
public function elements ( \ PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $ criteria ) { $ values = $ this -> postCommand ( 'elements' , $ criteria ) ; $ elements = array ( ) ; foreach ( $ values as $ value ) { $ elements [ ] = Element :: fromResponseValue ( $ value , $ this -> url -> descend ( 'element' ) , $ ...
Finds elements using given criteria .
59,924
public function getRequiredModules ( $ moduleName ) { $ moduleName = strtolower ( $ moduleName ) ; if ( isset ( $ this -> _requiredModules [ $ moduleName ] ) ) { return $ this -> _requiredModules [ $ moduleName ] ; } else { return null ; } }
Gets a module
59,925
public function readConfig ( $ configFile ) { $ yamlParser = new \ Symfony \ Component \ Yaml \ Parser ( ) ; $ userConfPath = ROOT . DS . 'app' . DS . 'config' . DS . 'modules' . DS . $ configFile ; $ userCustomPath = ROOT . DS . 'app' . DS . 'modules' . DS . $ configFile ; $ composerConfPath = ROOT . DS . 'modules' . ...
Reads the configuration file ad returns a configuration array
59,926
public function addSharedInstance ( $ instance , $ classOrAlias ) { if ( ! is_object ( $ instance ) ) { throw new Exception ( 'This method requires an object to be shared. Class or Alias given: ' . $ classOrAlias ) ; } $ this -> sharedInstances [ $ classOrAlias ] = $ instance ; }
Add shared instance
59,927
public function getSharedInstanceWithParameters ( $ classOrAlias , array $ params , $ fastHashFromHasLookup = null ) { if ( $ fastHashFromHasLookup ) { return $ this -> sharedInstancesWithParams [ 'hashLong' ] [ $ fastHashFromHasLookup ] ; } ksort ( $ params ) ; $ hashKey = $ this -> createHashForKeys ( $ classOrAlias ...
Retrieves an instance by its name and the parameters stored at its instantiation
59,928
public function hasConfig ( $ aliasOrClass ) { $ key = ( $ this -> hasAlias ( $ aliasOrClass ) ) ? 'alias:' . $ this -> getBaseAlias ( $ aliasOrClass ) : $ aliasOrClass ; if ( ! isset ( $ this -> configurations [ $ key ] ) ) { return false ; } if ( $ this -> configurations [ $ key ] === $ this -> configurationTemplate ...
Check for configuration
59,929
public function hasTypePreferences ( $ interfaceOrAbstract ) { $ key = ( $ this -> hasAlias ( $ interfaceOrAbstract ) ) ? 'alias:' . $ interfaceOrAbstract : $ interfaceOrAbstract ; return ( isset ( $ this -> typePreferences [ $ key ] ) && $ this -> typePreferences [ $ key ] ) ; }
Check for type preferences
59,930
public function setTypePreference ( $ interfaceOrAbstract , array $ preferredImplementations ) { $ key = ( $ this -> hasAlias ( $ interfaceOrAbstract ) ) ? 'alias:' . $ interfaceOrAbstract : $ interfaceOrAbstract ; foreach ( $ preferredImplementations as $ preferredImplementation ) { $ this -> addTypePreference ( $ key...
Set type preference
59,931
public function getTypePreferences ( $ interfaceOrAbstract ) { $ key = ( $ this -> hasAlias ( $ interfaceOrAbstract ) ) ? 'alias:' . $ interfaceOrAbstract : $ interfaceOrAbstract ; if ( isset ( $ this -> typePreferences [ $ key ] ) ) { return $ this -> typePreferences [ $ key ] ; } return [ ] ; }
Get type preferences
59,932
public function unsetTypePreferences ( $ interfaceOrAbstract ) { $ key = ( $ this -> hasAlias ( $ interfaceOrAbstract ) ) ? 'alias:' . $ interfaceOrAbstract : $ interfaceOrAbstract ; unset ( $ this -> typePreferences [ $ key ] ) ; }
Unset type preferences
59,933
public function removeTypePreference ( $ interfaceOrAbstract , $ preferredType ) { $ key = ( $ this -> hasAlias ( $ interfaceOrAbstract ) ) ? 'alias:' . $ interfaceOrAbstract : $ interfaceOrAbstract ; if ( ! isset ( $ this -> typePreferences [ $ key ] ) || ! Arrays :: in ( $ preferredType , $ this -> typePreferences [ ...
Removes a previously set type preference
59,934
protected function toAssocRecursive ( $ input , SplObjectStorage $ list ) : array { $ values = is_iterable ( $ input ) ? i \ iterable_to_array ( $ input ) : object_get_properties ( $ input , $ input instanceof stdClass || $ input instanceof DynamicEntity ) ; foreach ( $ values as $ key => & $ value ) { if ( $ value ins...
Recursively cast to associative arrays .
59,935
public function getStills ( ) { if ( ! isset ( $ this -> stills ) ) { $ this -> stills = [ new Still ( $ this -> thumbnail_url , 'default' ) , new Still ( $ this -> thumbnail_url_lq , 'lq' ) , new Still ( $ this -> thumbnail_url_mq , 'mq' ) , ] ; } return $ this -> stills ; }
Generate a list of Still entities based on other properties that come from VM 6 .
59,936
private function get ( String $ id ) { if ( ! $ id ) { $ id = ConnectionManager :: DEFAULT_CONNECTION_ID ; } if ( count ( $ this -> loadedConnections ) < 1 ) { return false ; } if ( isset ( $ this -> loadedConnections [ $ id ] ) ) { $ this -> configuredConnectionId = $ id ; $ this -> platformConnector = [ $ id => $ thi...
Try to connection with this id from the loaded connections in the configuration file .
59,937
public static function toString ( ) { $ return = [ ] ; foreach ( static :: $ globals as $ key => $ value ) { $ type = gettype ( $ value ) ; if ( is_callable ( $ value ) ) { $ valueString = 'callable' ; $ type = 'callable' ; } elseif ( is_array ( $ value ) ) { $ valueString = implode ( ', ' , $ value ) ; } else { $ valu...
Return keys and values of global variables as string
59,938
public function actionEditableSaver ( ) { Yii :: import ( 'EditableSaver' ) ; $ es = new EditableSaver ( 'CcucUserCompany' ) ; $ es -> update ( ) ; if ( $ es -> attribute != 'ccuc_status' ) { return ; } if ( $ es -> value != CcucUserCompany :: CCUC_STATUS_USER ) { return ; } $ m = Person :: model ( ) ; return $ m -> cr...
for company ccuc on change status to USER create customer office uses
59,939
public function load ( $ name ) { $ factoryClass = ucfirst ( $ name ) . "Phactory" ; if ( ! class_exists ( $ factoryClass ) ) { throw new \ Exception ( "Unknown factory '$name'" ) ; } return new Factory ( $ name , new $ factoryClass ) ; }
Loads the factory according to the object class name
59,940
public static function generateValidXmlFromArray ( $ array , $ node_block = 'response' , $ node_name = 'item' ) { $ xml = '<?xml version="1.0" encoding="UTF-8" ?>' ; $ xml .= '<' . $ node_block . '>' ; $ xml .= self :: generateXmlFromArray ( $ array , $ node_name ) ; $ xml .= '</' . $ node_block . '>' ; return $ xml ; ...
Generate valid xml from array
59,941
private static function generateXmlFromArray ( $ array , $ node_name ) { $ xml = '' ; if ( is_array ( $ array ) || is_object ( $ array ) ) { foreach ( $ array as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ key = $ node_name ; } $ xml .= '<' . $ key . '>' . self :: generateXmlFromArray ( $ value , $ node_name )...
Generate XML from array
59,942
protected function addDeferLog ( $ role , $ level , $ message , $ context ) { $ this -> deferLogs [ ] = compact ( 'role' , 'level' , 'message' , 'context' ) ; $ this -> deferLogsCount ++ ; }
Add a defer log
59,943
protected function removeDeferLog ( $ k ) { if ( ! isset ( $ this -> deferLogs [ $ k ] ) ) { return ; } unset ( $ this -> deferLogs [ $ k ] ) ; $ this -> deferLogsCount -- ; }
Remove a defer log
59,944
public function flush ( ) { foreach ( $ this -> deferLogs as $ k => $ deferLog ) { $ this -> record ( $ deferLog [ 'message' ] , $ deferLog [ 'context' ] , $ deferLog [ 'level' ] , $ deferLog [ 'role' ] ) ; $ this -> removeDeferLog ( $ k ) ; } }
Flush defer logs
59,945
protected function addCacheDirectory ( ContainerInterface $ container , SerializerBuilder $ builder ) : void { $ config = $ container -> get ( 'config' ) ; $ libraryConfig = $ config [ ConfigKey :: PROJECT ] [ ConfigKey :: API_CLIENT ] ?? [ ] ; $ cacheDir = ( string ) ( $ libraryConfig [ ConfigKey :: CACHE_DIR ] ?? '' ...
Adds the cache directory from the config to the builder .
59,946
public function setOptions ( $ options ) { if ( ! is_array ( $ options ) && ! $ options instanceof Traversable ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected an array or Traversable; received "%s"' , ( is_object ( $ options ) ? get_class ( $ options ) : gettype ( $ options ) ) ) ) ; } foreach ( $ option...
Configure service broker
59,947
public function getDefaultIdentity ( ) { if ( ! $ this -> defaultIdentity ) { $ this -> defaultIdentity = new ArrayObject ( array ( ) ) ; if ( $ this -> exists ( 'Identity' ) ) { $ responses = $ this -> execute ( 'Identity' , 'getIdentity' , array ( ) , function ( $ response ) { if ( $ response instanceof ArrayAccess )...
Retrieve default identity
59,948
public function setLoader ( ServiceLoader $ loader ) { $ this -> loader = $ loader ; $ that = $ this ; $ this -> loader -> addInitializer ( function ( $ instance ) use ( $ that ) { if ( $ instance instanceof Feature \ ServiceBrokerAwareInterface ) { $ instance -> setServiceBroker ( $ that ) ; } if ( $ instance instance...
Set service loader instance
59,949
public function service ( $ service ) { if ( ! $ this -> exists ( $ service ) ) { throw new ServiceNotFoundException ( sprintf ( 'Service "%s" not found' , $ service ) ) ; } return new Worker ( $ this , $ service ) ; }
Initialize and retrieve a new service Worker
59,950
public function executeInContext ( $ context , $ service , $ operation , $ argv = array ( ) , $ callback = null ) { $ command = new Command ( $ service , $ operation , $ argv , $ context ) ; return $ this -> dispatch ( $ command , $ callback ) ; }
Execute service operation in context
59,951
public function queue ( CommandInterface $ command , array $ options = [ ] ) { $ queueName = null ; if ( array_key_exists ( self :: QUEUE_OPTION_NAME , $ options ) ) { $ queueName = $ options [ self :: QUEUE_OPTION_NAME ] ? : null ; unset ( $ options [ self :: QUEUE_OPTION_NAME ] ) ; } $ queue = $ this -> getQueue ( $ ...
Queue execution of service operation
59,952
protected function createEvent ( $ name , CommandInterface $ command ) { $ event = new ServiceEvent ( ) ; $ event -> setName ( $ name ) ; $ event -> setCommand ( $ command ) ; $ event -> setParams ( $ command -> getParams ( ) ) ; return $ event ; }
Create a new service event
59,953
public function getCurrency ( ) { $ options = [ 'EUR' => __ ( 'Euro' ) , 'GBP' => __ ( 'Sterling' ) , 'USD' => __ ( 'US Dollar' ) , 'CAD' => __ ( 'Canadian Dollar' ) , 'AUD' => __ ( 'Australian Dollar' ) , 'DKK' => __ ( 'Danish Krone' ) , 'SEK' => __ ( 'Swedish Krona' ) , 'NOK' => __ ( 'Norwegian Krone' ) ] ; return $ ...
Get Grid row currency labels array .
59,954
protected function processComment ( ) { $ comment = strtr ( trim ( preg_replace ( '/^\s*\**( |\t)?/m' , '' , trim ( $ this -> getDocComment ( ) , '/' ) ) ) , "\r" , '' ) ; if ( preg_match ( '/^\s*@\w+/m' , $ comment , $ matches , PREG_OFFSET_CAPTURE ) ) { $ meta = substr ( $ comment , $ matches [ 0 ] [ 1 ] ) ; $ this -...
gets tags lines from docblock
59,955
protected function processTags ( $ comment ) { $ tags = preg_split ( '/^\s*@/m' , $ comment , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ tags as $ tag ) { $ segs = preg_split ( '/\s+/' , trim ( $ tag ) , 2 ) ; $ tagName = $ segs [ 0 ] ; $ param = isset ( $ segs [ 1 ] ) ? trim ( $ segs [ 1 ] ) : '' ; $ this -> tags [ $ t...
extracts tags array from docblock
59,956
public function getFactory ( Specification $ spec ) : Factory { if ( ! isset ( $ this -> factories [ get_class ( $ spec ) ] ) ) { throw new \ OutOfRangeException ( sprintf ( 'Factory for Specification "%s" not registred' , get_class ( $ spec ) ) ) ; } return $ this -> factories [ get_class ( $ spec ) ] ; }
Get registred factory for Specification
59,957
public function retry ( int $ delayed = 0 ) : void { $ this -> link -> req ( $ this -> id ( ) , $ delayed ) ; }
delayed in milliseconds
59,958
public function parse ( $ template ) { $ viewsFromConfig = $ this -> app [ 'config' ] -> get ( 'view.paths' ) ; $ views = array_merge ( ( array ) $ viewsFromConfig , ( array ) $ this -> paths [ 'theme' ] ) ; $ cache = $ this -> paths [ 'storage' ] . '/views' ; $ blade = new BladeAdapter ( $ views , $ cache ) ; if ( ! $...
Handle the compilation of the templates
59,959
protected function validateType ( $ value ) { if ( ! $ value instanceof Closure && $ value !== null ) { $ exception = new InvalidTypeException ( sprintf ( 'Invalid type for path "%s". Expected closure, but got %s.' , $ this -> getPath ( ) , gettype ( $ value ) ) ) ; if ( $ hint = $ this -> getInfo ( ) ) { $ exception -...
Validates the type of a Node .
59,960
private function addProcessInfo ( Process $ process , Project $ project ) { $ this -> processes [ $ project -> getName ( ) ] = [ 'process' => $ process , 'project' => $ project , ] ; }
Adds the process and project info .
59,961
private function workaroundForSingleChar ( string & $ incrementalOutput , Project $ project ) { if ( ! empty ( $ this -> tmpChar [ $ project -> getName ( ) ] ) && ! empty ( $ incrementalOutput ) ) { $ incrementalOutput = $ this -> tmpChar [ $ project -> getName ( ) ] . $ incrementalOutput ; $ this -> tmpChar [ $ projec...
Workaround for single char .
59,962
protected function handleProcessOutput ( array $ processInfo , BufferedOutputInterface $ output , callable $ processTerminatedCallback ) { $ process = $ processInfo [ 'process' ] ; $ project = $ processInfo [ 'project' ] ; if ( ! $ process -> isStarted ( ) ) { $ process -> start ( ) ; } $ incrementalOutput = $ this -> ...
Handles the output for a process .
59,963
public function get ( $ keyName , $ defaultValue = null ) { $ this -> initList ( ) ; $ keyName = strtolower ( $ keyName ) ; if ( empty ( $ this -> list [ $ keyName ] ) ) { return $ defaultValue ; } return $ this -> list [ $ keyName ] ; }
Gets value of by key name .
59,964
private function generateSwitchResponse ( $ client , $ request ) { $ acceptHeader = sha1 ( $ request -> getHeader ( "sec-websocket-key" ) . self :: WEBSOCKET_GUID , true ) ; $ switchParams = array ( "Upgrade" => "websocket" , "Connection" => "Upgrade" , "Sec-WebSocket-Accept" => base64_encode ( $ acceptHeader ) ) ; $ r...
Generates WebSocket upgrade response & notifies clients handler
59,965
private function verifyUpgradeRequest ( HttpRequest $ request ) { $ this -> logger -> debug ( "Attempting to switch protocols (checking preconditions per RFC)" ) ; if ( $ request -> getMethod ( ) !== "GET" ) { throw new HttpException ( "Cannot upgrade to WebSocket - invalid method" , HttpCode :: METHOD_NOT_ALLOWED ) ; ...
Validates HTTP = > WebSocket upgrade request
59,966
private function populatePaths ( $ paths ) { if ( ! is_array ( $ paths ) ) { $ paths = array ( $ paths ) ; } foreach ( $ paths as $ path ) { if ( $ path [ 0 ] !== "/" && $ path [ 0 ] !== "*" ) { throw new InvalidArgumentException ( "Invalid handler path specified" ) ; } $ this -> handlerPaths [ ] = $ path ; } }
Verifies & adds paths handled by this handler It s private due to fact that for performance reasons CherryHttp will cache paths for each handler
59,967
public function getBaseTmpDir ( ) { $ folders = explode ( DIRECTORY_SEPARATOR , $ this -> getRootDir ( ) ) ; $ foldersCount = count ( $ folders ) ; $ projectDir = '' ; if ( true === isset ( $ folders [ $ foldersCount - 2 ] ) ) { $ projectDir = $ folders [ $ foldersCount - 2 ] ; } $ tempDirPath = FileUtility :: getUserB...
Get Base Tmp Dir
59,968
public function describe ( $ serviceId ) { $ cache = $ this -> getCache ( ) ; $ cacheId = self :: CACHE_ID_PREFIX . $ serviceId ; if ( $ cache && ( $ description = $ this -> getCache ( ) -> getItem ( $ cacheId ) ) ) { return $ description ; } $ loader = $ this -> getServiceLoader ( ) ; $ options = $ loader -> getServic...
Retrieve service description
59,969
public function get ( $ html ) { $ kernel_dir = $ this -> kerneldir ; require __DIR__ . "/../Resources/config/dompdf.php" ; $ this -> pdf = new DOMPDF ; foreach ( $ this -> options as $ optionKey => $ optionValue ) { $ this -> pdf -> set_option ( $ optionKey , $ optionValue ) ; } $ this -> pdf -> load_html ( $ html ) ;...
Get PDF By HTML
59,970
public function set ( $ key , $ value = null ) { i \ type_check ( $ key , [ 'array' , 'string' ] ) ; if ( func_num_args ( ) === 1 && is_string ( $ key ) ) { throw new BadMethodCallException ( sprintf ( "Too few arguments to method %s::%s(). If first argument is a string, a second argument is required" , __CLASS__ , __F...
Set a value or multiple values .
59,971
public function aria ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'aria-' . $ type ] = $ element ; return $ this ; }
Sets aria attribute
59,972
public function data ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'data-' . $ type ] = $ element ; return $ this ; }
Sets data attribute
59,973
public function spry ( String $ type , String $ element ) { $ this -> settings [ 'attr' ] [ 'spry-' . $ type ] = $ element ; return $ this ; }
Sets spry attribute
59,974
public static function getSuccessDatum ( $ meta = [ ] , $ data = null , $ html = false ) { $ defaultMeta = array ( 'result' => OperationResult :: SUCCESS , 'type' => OperationResult :: getType ( OperationResult :: SUCCESS ) , 'time' => date ( 'Y-m-d H:i:s' ) , 'message' => Yii :: t ( 'cza' , 'Operation completed.' ) ) ...
standardize the datum format
59,975
public function getItems ( ) { $ statement = ( null !== $ this -> c && null !== $ this -> d ) ? $ this -> getStatementDay ( ) : $ this -> getStatementPagination ( ) ; $ result = $ statement -> execute ( ( is_array ( $ this -> select ) ) ? $ this -> select [ 1 ] : null ) ; $ resultSet = clone $ this -> resultSetPrototyp...
Returns an ResultSet of items for a page .
59,976
public function getStatementDay ( ) { if ( null === $ this -> n ) { $ this -> n = 1 ; } $ date = new \ DateTime ( $ this -> d , new \ DateTimeZone ( 'UTC' ) ) ; $ date -> sub ( new \ DateInterval ( sprintf ( 'P%dD' , ( $ this -> p * $ this -> n ) - 1 ) ) ) ; $ start_date = $ date -> format ( 'Y-m-j' ) ; $ date -> add (...
Get Statement Pagination By Date
59,977
public function getTotalItemCount ( ) { if ( $ this -> rowCount !== null ) { return $ this -> rowCount ; } $ param = null ; if ( is_array ( $ this -> select ) ) { $ select = $ this -> select [ 0 ] ; $ param = $ this -> select [ 1 ] ; $ adt = $ this -> sql -> getAdapter ( ) ; $ statement = $ adt -> query ( sprintf ( "SE...
Returns the total number of rows in the result set
59,978
private function checkColumns ( $ ok , $ table , $ cols ) { $ fords = false ; foreach ( $ cols as $ ck => $ cv ) { if ( $ cv instanceof Expression || $ cv instanceof Select || is_string ( $ cv ) ) { if ( $ ok === $ ck ) { $ fords = $ ok ; break ; } elseif ( ( $ cv instanceof Expression && $ ok === $ cv -> getExpression...
Check Column name
59,979
static function make ( $ mime , $ param = null , $ paramValue = null ) { if ( null === $ param || null === $ paramValue ) { return $ mime ; } return "$mime;$param=$paramValue" ; }
USEFUL STATIC METHODS
59,980
final protected function addImageSize ( $ name , $ width , $ height , $ crop = false ) { $ this -> getWpBridge ( ) -> addImageSize ( $ name , $ width , $ height , $ crop ) ; }
Register a WP image size .
59,981
public function createUrl ( $ params = array ( ) ) { return Yii :: app ( ) -> createUrl ( $ this -> route , CMap :: mergeArray ( $ params , $ this -> evaluateParams ( $ this -> params ) ) ) ; }
Returns the URL for this model .
59,982
protected function evaluateParams ( $ params ) { foreach ( $ params as $ name => $ value ) { if ( is_callable ( $ value ) ) $ params [ $ name ] = $ this -> evaluateExpression ( $ value , array ( 'data' => $ this -> owner ) ) ; } return $ params ; }
Evaluates the given params .
59,983
public function findAll ( ) { $ a = [ ] ; foreach ( $ this -> parents as $ x => $ r ) { $ a [ $ x ] = $ this -> find ( $ x ) ; } return $ a ; }
Get map of all items - > representative
59,984
public function findDistinct ( ) { $ a = [ ] ; foreach ( $ this -> parents as $ x => $ r ) { $ a [ $ this -> find ( $ x ) ] = null ; } return array_keys ( $ a ) ; }
Get a representative for each component .
59,985
function loader ( $ loaderName ) { $ loaderName = $ this -> _normalizeLoaderName ( $ loaderName ) ; if ( ! $ this -> hasAttached ( $ loaderName ) ) throw new \ Exception ( sprintf ( 'Loader with name (%s) has not attached.' , $ loaderName ) ) ; return $ this -> _t_loader_aggregate_Names [ $ loaderName ] ; }
Get Loader By Name
59,986
function hasAttached ( $ loaderName ) { $ loaderName = $ this -> _normalizeLoaderName ( $ loaderName ) ; return in_array ( $ loaderName , $ this -> listAttached ( ) ) ; }
Has Loader With This Name Attached?
59,987
public function encrypt ( $ data ) { $ iv = openssl_random_pseudo_bytes ( $ this -> getSize ( ) ) ; $ value = openssl_encrypt ( serialize ( $ data ) , $ this -> method , $ this -> key , 0 , $ iv ) ; $ mac = $ this -> hash ( $ iv = base64_encode ( $ iv ) , $ value ) ; return base64_encode ( json_encode ( compact ( 'iv' ...
To encrypt data
59,988
public function decrypt ( $ data ) { $ json = base64_decode ( $ data ) ; $ data = json_decode ( $ json ) ; if ( $ this -> hashCheck ( $ data -> iv , $ data -> value , $ data -> mac ) ) { $ iv = base64_decode ( $ data -> iv ) ; $ data = openssl_decrypt ( $ data -> value , $ this -> method , $ this -> key , 0 , $ iv ) ; ...
To decrypt data
59,989
protected function hashCheck ( $ iv , $ value , $ mac ) { $ salt = Str :: random ( $ this -> keySize ) ; $ mainMac = hash_hmac ( 'sha256' , $ this -> hash ( $ iv , $ value ) , $ salt ) ; $ checkMac = hash_hmac ( 'sha256' , $ mac , $ salt ) ; if ( $ mainMac === $ checkMac ) { return true ; } return false ; }
To check mac
59,990
public function process ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ methodProperties = $ phpcsFile -> getMethodProperties ( $ stackPtr ) ; if ( $ methodProperties [ 'scope' ] !== 'public' ) { return ; } parent :: process ( $ phpcsFile , $ stackPtr ) ; }
Ensures only public methods are processed .
59,991
protected function checkSpacingAfterParamType ( PHP_CodeSniffer_File $ phpcsFile , $ param , $ maxType , $ spacing = 1 ) { $ spaces = ( $ maxType - strlen ( $ param [ 'type' ] ) + $ spacing ) ; if ( $ param [ 'type_space' ] !== $ spaces ) { $ error = 'Expected %s spaces after parameter type; %s found' ; $ data = array ...
Check the spacing after the type of a parameter .
59,992
public function writeString ( $ string ) { fwrite ( $ this -> stream , ' <si><t>' . Utils :: escape ( $ string ) . '</t></si>' . MyWriter :: EOL ) ; return $ this -> id ++ ; }
String MUST already be escaped
59,993
public function initDbTable ( $ table = null ) { if ( empty ( $ table ) ) { return false ; } $ initModel = ClassRegistry :: init ( Inflector :: classify ( $ table ) , true ) ; if ( $ initModel === false ) { return false ; } if ( ! method_exists ( $ initModel , 'initDbTable' ) ) { return false ; } $ ds = $ initModel -> ...
Initialization of database table the initial values
59,994
public function setCanvasColor ( array $ canvas_color ) : AbstractResize { if ( Helper :: colorIndexValid ( 'r' , $ canvas_color ) === false || Helper :: colorIndexValid ( 'g' , $ canvas_color ) === false || Helper :: colorIndexValid ( 'b' , $ canvas_color ) === false ) { throw new \ InvalidArgumentException ( Helper :...
Set a new canvas color
59,995
public function loadImage ( string $ file , string $ path = '' ) : AbstractResize { if ( file_exists ( $ path . $ file ) === true ) { $ this -> source [ 'path' ] = $ path ; $ this -> source [ 'file' ] = $ file ; $ this -> sourceProperties ( ) ; } else { throw new \ Exception ( "File couldn't be found in supplied destin...
Load the image
59,996
protected function sourceProperties ( ) { $ properties = Helper :: imageProperties ( $ this -> source [ 'file' ] , $ this -> source [ 'path' ] ) ; if ( $ properties [ 'width' ] !== null ) { $ this -> source [ 'width' ] = $ properties [ 'width' ] ; $ this -> source [ 'height' ] = $ properties [ 'height' ] ; $ this -> so...
Fetch the dimensions of the source image and calculate the aspect ratio . We also check to ensure that the image is being resized down currently we don t support upscaling the image
59,997
public function resizeSource ( ) : AbstractResize { if ( $ this -> intermediate [ 'maintain_aspect' ] === true ) { if ( $ this -> source [ 'aspect_ratio' ] > 1.00 ) { $ this -> intermediateSizeLandscape ( ) ; } else { if ( $ this -> source [ 'aspect_ratio' ] === 1.00 ) { $ this -> intermediateSizeSquare ( ) ; } else { ...
Process the request generate the size required for the image along with the canvas spacing
59,998
protected function intermediateSizeLandscape ( ) { $ this -> intermediate [ 'width' ] = $ this -> canvas [ 'width' ] ; $ this -> intermediate [ 'height' ] = intval ( round ( $ this -> intermediate [ 'width' ] / $ this -> source [ 'aspect_ratio' ] , 0 ) ) ; if ( $ this -> intermediate [ 'height' ] > $ this -> canvas [ '...
The source image is landscape maintaining aspect ratio calculate the intermediate image height and width
59,999
protected function intermediateSizeSquare ( ) { if ( $ this -> canvas [ 'height' ] === $ this -> canvas [ 'width' ] ) { $ this -> intermediate [ 'width' ] = $ this -> canvas [ 'width' ] ; $ this -> intermediate [ 'height' ] = $ this -> canvas [ 'height' ] ; } else { if ( $ this -> canvas [ 'width' ] > $ this -> canvas ...
The source image is landscape fit as appropriate