idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
2,500
public function addExportDocPosition ( $ exportDocPosition ) { if ( $ this -> getExportDocPosition ( ) === null ) $ this -> setExportDocPosition ( $ exportDocPosition ) ; else if ( is_array ( $ this -> getExportDocPosition ( ) ) ) $ this -> exportDocPosition [ ] = $ exportDocPosition ; else { $ this -> setExportDocPosi...
Adds an ExportDocPosition - Object to the current Object
2,501
public function getExportDocumentClass_v2 ( ) { $ class = new StdClass ; if ( $ this -> getInvoiceNumber ( ) !== null ) $ class -> invoiceNumber = $ this -> getInvoiceNumber ( ) ; $ class -> exportType = $ this -> getExportType ( ) ; if ( $ this -> getExportTypeDescription ( ) !== null ) $ class -> exportTypeDescriptio...
Returns a Class for Export - Document
2,502
public function getShipmentOrderClass_v2 ( ) { $ class = new StdClass ; $ class -> sequenceNumber = $ this -> getSequenceNumber ( ) ; $ class -> Shipment = new StdClass ; $ class -> Shipment -> ShipmentDetails = $ this -> getShipmentDetails ( ) -> getShipmentDetailsClass_v2 ( ) ; $ class -> Shipment -> Shipper = $ this...
Returns an DHL - Class of this Object for DHL - Shipment Order
2,503
public final function setCountry ( $ country ) { if ( $ country !== null ) $ this -> country = mb_strtolower ( $ country ) ; else $ this -> country = null ; }
Set the Country
2,504
public final function setCountryISOCode ( $ countryISOCode ) { if ( $ countryISOCode !== null ) $ this -> countryISOCode = mb_strtoupper ( $ countryISOCode ) ; else $ this -> countryISOCode = null ; }
Set the Country - ISO - Code
2,505
public final function setFullStreet ( $ street ) { trigger_error ( '[DHL-PHP-SDK]: Called deprecated method ' . __METHOD__ . ': Buggy on some addresses, please separate the number and street by yourself. This method will removed in the future!' , E_USER_DEPRECATED ) ; $ match = array ( ) ; preg_match ( '/^([^\d]*[^\d\s...
Sets Street - Name and Number by Address String
2,506
public function setDayOfDeliveryDate ( $ dayOfDeliveryDate , $ useIntTime = false ) { if ( $ useIntTime ) { $ dayOfDeliveryDate = date ( 'Y-m-d' , $ dayOfDeliveryDate ) ; if ( $ dayOfDeliveryDate === false ) $ dayOfDeliveryDate = null ; } $ this -> dayOfDeliveryDate = $ dayOfDeliveryDate ; }
Set the Date for the Service DayOfDelivery
2,507
private function loadLabelData_v2 ( $ response ) { $ labelResponse = $ response ; if ( isset ( $ response -> LabelData ) ) $ labelResponse = $ response -> LabelData ; if ( isset ( $ response -> sequenceNumber ) ) $ this -> setSequenceNumber ( ( string ) $ response -> sequenceNumber ) ; else if ( isset ( $ labelResponse...
Set all Values of the LabelResponse to this Object
2,508
public function getBankClass_v2 ( ) { $ class = new StdClass ; $ class -> accountOwner = $ this -> getAccountOwnerName ( ) ; $ class -> bankName = $ this -> getBankName ( ) ; $ class -> iban = $ this -> getIban ( ) ; if ( $ this -> getNote1 ( ) !== null ) $ class -> note1 = $ this -> getNote1 ( ) ; if ( $ this -> getNo...
Returns a DHL - Bank - Class for API v2
2,509
public function setShipmentDate ( $ shipmentDate , $ useIntTime = false ) { if ( $ useIntTime ) { $ shipmentDate = date ( 'Y-m-d' , $ shipmentDate ) ; if ( $ shipmentDate === false ) $ shipmentDate = null ; } $ this -> shipmentDate = $ shipmentDate ; }
Set the Shipment - Date
2,510
public function getShipmentDetailsClass_v2 ( ) { $ class = new StdClass ; $ class -> product = $ this -> getProduct ( ) ; $ class -> accountNumber = $ this -> getAccountNumber ( ) ; if ( $ this -> getCustomerReference ( ) !== null ) $ class -> customerReference = $ this -> getCustomerReference ( ) ; $ class -> shipment...
Returns an DHL - Class of this Object for DHL - Shipment Details
2,511
public function RenderSteam2 ( ) { switch ( $ this -> GetAccountType ( ) ) { case self :: TypeInvalid : case self :: TypeIndividual : { $ Universe = $ this -> GetAccountUniverse ( ) ; $ AccountID = $ this -> GetAccountID ( ) ; return 'STEAM_' . $ Universe . ':' . ( $ AccountID & 1 ) . ':' . ( $ AccountID >> 1 ) ; } def...
Renders this instance into it s Steam2 STEAM_ representation .
2,512
public function RenderSteam3 ( ) { $ AccountInstance = $ this -> GetAccountInstance ( ) ; $ AccountType = $ this -> GetAccountType ( ) ; $ AccountTypeChar = isset ( self :: $ AccountTypeChars [ $ AccountType ] ) ? self :: $ AccountTypeChars [ $ AccountType ] : 'i' ; $ RenderInstance = false ; switch ( $ AccountType ) {...
Renders this instance into its Steam3 representation .
2,513
public function IsValid ( ) { $ AccountType = $ this -> GetAccountType ( ) ; if ( $ AccountType <= self :: TypeInvalid || $ AccountType >= 11 ) { return false ; } $ AccountUniverse = $ this -> GetAccountUniverse ( ) ; if ( $ AccountUniverse <= self :: UniverseInvalid || $ AccountUniverse >= self :: UniverseMax ) { retu...
Gets a value indicating whether this instance is valid .
2,514
public function SetFromUInt64 ( $ Value ) { if ( self :: IsNumeric ( $ Value ) ) { $ this -> Data = gmp_init ( $ Value , 10 ) ; } else { throw new InvalidArgumentException ( 'Provided SteamID is not numeric.' ) ; } return $ this ; }
Sets the various components of this SteamID from a 64bit integer form .
2,515
public function make ( array $ config ) : Facebook { $ config = $ this -> getConfig ( $ config ) ; return $ this -> getClient ( $ config ) ; }
Make a new facebook client .
2,516
public function request ( string $ verb , string $ path , array $ query = [ ] , array $ options = [ ] ) { $ options [ 'query' ] = $ query ; if ( ! empty ( $ options [ 'query' ] [ 'filter' ] ) && is_array ( $ options [ 'query' ] [ 'filter' ] ) ) { $ options [ 'query' ] [ 'filter' ] = implode ( ',' , $ options [ 'query' ...
Takes parameters passed in makes a request to the API and processes the response .
2,517
public function makeRequest ( string $ verb , string $ path , array $ query = [ ] , array $ options = [ ] ) { try { $ response = $ this -> client -> $ verb ( self :: BASE_URI . $ path , $ options ) ; } catch ( ClientException $ e ) { print $ e -> getMessage ( ) ; $ response = $ e -> getResponse ( ) ; } return $ respons...
Makes a request to the API .
2,518
public function processResponse ( ResponseInterface $ response ) { $ body = $ response -> getBody ( ) ; $ object = json_decode ( $ body ) ; if ( json_last_error ( ) === JSON_ERROR_NONE ) { if ( property_exists ( $ object , '_embedded' ) && property_exists ( $ object -> _embedded , 'items' ) ) { $ return = $ object -> _...
Processes the returned response from the API .
2,519
public function addQuery ( $ name , $ value ) { $ this -> query = array_merge_recursive ( $ this -> query , [ $ name => $ value ] ) ; }
Add a query parameter to filter results .
2,520
public function databaseCopy ( $ environmentFromUuid , $ dbName , $ environmentToUuid ) { $ options = [ 'form_params' => [ 'name' => $ dbName , 'source' => $ environmentFromUuid , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentToUuid}/databases" , $ this -> ...
Copies a database from an environment to an environment .
2,521
public function databaseBackup ( $ environmentUuid , $ dbName , $ backupId ) { return new BackupResponse ( $ this -> connector -> request ( 'get' , "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}" , $ this -> query ) ) ; }
Gets information about a database backup .
2,522
public function restoreDatabaseBackup ( $ environmentUuid , $ dbName , $ backupId ) { return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/restore" , $ this -> query ) ) ; }
Restores a database backup to a database in an environment .
2,523
public function copyFiles ( $ environmentUuidFrom , $ environmentUuidTo ) { $ options = [ 'form_params' => [ 'source' => $ environmentUuidFrom , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuidTo}/files" , $ this -> query , $ options ) ) ; }
Copies files from an environment to another environment .
2,524
public function deployCode ( $ environmentFromUuid , $ environmentToUuid , $ commitMessage = null ) { $ options = [ 'form_params' => [ 'source' => $ environmentFromUuid , 'message' => $ commitMessage , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentToUuid}/c...
Deploys code from one environment to another environment .
2,525
public function createDomain ( $ environmentUuid , $ hostname ) { $ options = [ 'form_params' => [ 'hostname' => $ hostname , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/domains" , $ this -> query , $ options ) ) ; }
Adds a domain to an environment .
2,526
public function purgeVarnishCache ( $ environmentUuid , array $ domains ) { $ options = [ 'form_params' => [ 'domains' => $ domains , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/domains/actions/clear-varnish" , $ this -> query , $ options ) ) ; }
Purges varnish for selected domains in an environment .
2,527
public function renameEnvironment ( $ environmentUuid , $ label ) { $ options = [ 'form_params' => [ 'label' => $ label , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/actions/change-label" , $ this -> query , $ options ) ) ; }
Renames an environment .
2,528
public function disableLiveDev ( $ environmentUuid ) { $ options = [ 'form_params' => [ 'discard' => 1 , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/livedev/actions/disable" , $ this -> query , $ options ) ) ; }
Disable livedev mode for an environment .
2,529
public function createCron ( $ environmentUuid , $ command , $ frequency , $ label ) { $ options = [ 'form_params' => [ 'command' => $ command , 'frequency' => $ frequency , 'label' => $ label , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/environments/${environmentUuid}/crons" , $...
Add a cron task .
2,530
public function updateRole ( $ roleUuid , array $ permissions ) { $ options = [ 'form_params' => [ 'permissions' => $ permissions , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'put' , "/roles/${roleUuid}" , $ this -> query , $ options ) ) ; }
Update the permissions associated with a role .
2,531
public function createRole ( $ organizationUuid , $ name , array $ permissions , $ description = null ) { $ options = [ 'form_params' => [ 'name' => $ name , 'permissions' => $ permissions , 'description' => $ description , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/organizations...
Create a new role .
2,532
public function renameTeam ( $ teamUuid , $ name ) { $ options = [ 'form_params' => [ 'name' => $ name , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'put' , "/teams/${teamUuid}" , $ options ) ) ; }
Rename an existing team .
2,533
public function createTeam ( $ organizationUuid , $ name ) { $ options = [ 'form_params' => [ 'name' => $ name , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/organizations/${organizationUuid}/teams" , $ this -> query , $ options ) ) ; }
Create a new team .
2,534
public function addApplicationToTeam ( $ teamUuid , $ applicationUuid ) { $ options = [ 'form_params' => [ 'uuid' => $ applicationUuid , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/teams/${teamUuid}/applications" , $ this -> query , $ options ) ) ; }
Add an application to a team .
2,535
public function createTeamInvite ( $ teamUuid , $ email , $ roles ) { $ options = [ 'form_params' => [ 'email' => $ email , 'roles' => $ roles ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/teams/${teamUuid}/invites" , $ options ) ) ; }
Invites a user to join a team .
2,536
public function createOrganizationAdminInvite ( $ organizationUuid , $ email ) { $ options = [ 'form_params' => [ 'email' => $ email , ] , ] ; return new OperationResponse ( $ this -> connector -> request ( 'post' , "/teams/${organizationUuid}/invites" , $ this -> query , $ options ) ) ; }
Invites a user to become admin of an organization .
2,537
public function shorten ( $ url ) { $ link = new Link ; $ link -> setLongUrl ( $ url ) ; $ this -> provider -> shorten ( $ link ) ; return $ link -> getShortUrl ( ) ; }
Shorten the given url
2,538
public function driver ( $ driverName ) { $ shortener = new UrlShortener ( $ this -> driverFactory ) ; $ shortener -> setDriver ( $ driverName ) ; return $ shortener ; }
Creates a new URL Shortener instance with the given driver name . Useful for chained calls using the facade when a different driver is to be used for just one request .
2,539
public function make ( $ driverName ) { $ driverName = trim ( strtolower ( $ driverName ) ) ; switch ( $ driverName ) { case 'google' : return $ this -> google ; case 'bitly' : return $ this -> bitly ; default : throw new InvalidArgumentException ( 'Invalid URL Shortener driver name' ) ; } }
Create a new Url Shortener driver instance based on its name
2,540
private function getCheckboxChecked ( $ option ) { $ fieldElements = $ this -> getXpath ( ) -> findFields ( $ option ) ; EzAssertion :: assertElementFound ( $ option , $ fieldElements , null , 'checkbox' ) ; if ( strtolower ( $ fieldElements [ 0 ] -> getAttribute ( 'type' ) ) !== 'checkbox' ) { $ value = $ fieldElement...
Helper for checkbox
2,541
public function publishDraft ( Content $ content ) { $ this -> getRepository ( ) -> sudo ( function ( Repository $ repository ) use ( $ content ) { $ repository -> getContentService ( ) -> publishVersion ( $ content -> versionInfo -> id ) ; } ) ; }
Publishes a content draft .
2,542
protected function destroy ( ValueObject $ object ) { $ repository = $ this -> getRepository ( ) ; $ contentId = $ object -> id ; $ repository -> sudo ( function ( ) use ( $ repository , $ contentId ) { try { $ contentService = $ repository -> getContentService ( ) ; $ contentInfo = $ contentService -> loadContentInfo ...
Deletes the content object provided used to clean after testing
2,543
static function setProperties ( ValueObjectInterface $ object , array $ values ) { foreach ( $ values as $ property => $ value ) { $ this -> setProperty ( $ object , $ property , $ value ) ; } }
Sets an objects properties
2,544
public function searchUserGroups ( $ name , $ parentLocationId = null ) { return $ this -> getContext ( ) -> getUserGroupManager ( ) -> searchUserGroups ( $ name , $ parentLocationId ) ; }
Search User Groups with given name
2,545
public function loadUser ( $ id ) { $ repository = $ this -> getRepository ( ) ; $ userService = $ repository -> getUserService ( ) ; $ user = $ repository -> sudo ( function ( ) use ( $ id , $ userService ) { return $ userService -> loadUser ( $ id ) ; } ) ; return $ user ; }
Load a User by id
2,546
public function loadUserByLogin ( $ login ) { $ repository = $ this -> getRepository ( ) ; $ userService = $ repository -> getUserService ( ) ; $ user = $ repository -> sudo ( function ( ) use ( $ login , $ userService ) { return $ userService -> loadUserByLogin ( $ login ) ; } ) ; return $ user ; }
Load a User by login
2,547
public function updateUser ( $ user , $ fields = array ( ) ) { $ repository = $ this -> getRepository ( ) ; $ contentService = $ repository -> getContentService ( ) ; $ userService = $ repository -> getUserService ( ) ; $ userUpdateStruct = $ userService -> newUserUpdateStruct ( ) ; $ contentUpdateStruct = $ contentSer...
Update user with given field and value
2,548
private function publishContent ( $ field , $ value ) { $ repository = $ this -> getRepository ( ) ; $ languageCode = self :: DEFAULT_LANGUAGE ; $ content = $ repository -> sudo ( function ( ) use ( $ repository , $ languageCode , $ field , $ value ) { $ contentService = $ repository -> getcontentService ( ) ; $ locati...
Publishes the content
2,549
private function createContentType ( ) { $ repository = $ this -> getRepository ( ) ; $ contentTypeService = $ repository -> getContentTypeService ( ) ; $ name = $ this -> fieldConstructionObject [ 'fieldType' ] -> identifier ; $ name = uniqid ( $ name . '#' , true ) ; $ name = str_replace ( '.' , '' , $ name ) ; $ ide...
Creates an instance of a contenttype and stores it for later publishing
2,550
private function findNonExistingUserEmail ( $ username = 'User' ) { $ userManager = $ this -> getUserManager ( ) ; $ email = "${username}@ez.no" ; if ( $ userManager -> checkUserExistenceByEmail ( $ email ) ) { return $ email ; } for ( $ i = 0 ; $ i < 20 ; $ i ++ ) { $ email = uniqid ( 'User#' , true ) . '@ez.no' ; if ...
Find a non existing User email
2,551
private function findNonExistingUserName ( ) { $ userManager = $ this -> getUserManager ( ) ; for ( $ i = 0 ; $ i < 20 ; $ i ++ ) { $ username = substr ( uniqid ( 'User#' , true ) , 0 , 15 ) ; if ( ! $ userManager -> checkUserExistenceByUsername ( $ username ) ) { return $ username ; } } throw new \ Exception ( 'Possib...
Find a non existing User name
2,552
private function findNonExistingContentTypeGroupIdentifier ( ) { $ i = 0 ; while ( $ i ++ < 20 ) { $ identifier = 'ctg' . rand ( 10000 , 99999 ) ; if ( ! $ this -> checkContentTypeGroupExistenceByIdentifier ( $ identifier ) ) { return $ identifier ; } } throw new \ Exception ( 'Possible endless loop when attempting to ...
Find a non existing ContentTypeGroup identifier
2,553
private function findNonExistingUserGroupId ( ) { $ userGroupManager = $ this -> getUserGroupManager ( ) ; for ( $ i = 0 ; $ i < 20 ; $ i ++ ) { $ id = uniqid ( 'UserGroup#' , true ) ; if ( ! $ userGroupManager ( ) -> checkUserGroupExistence ( $ id ) ) { return $ id ; } } throw new \ Exception ( 'Possible endless loop ...
Find an non existent UserGroup id
2,554
private function getMethodAnnotations ( $ refClass , $ method = '__construct' ) { $ refMethod = $ refClass -> getMethod ( $ method ) ; preg_match_all ( '#@(.*?)\n#s' , $ refMethod -> getDocComment ( ) , $ matches ) ; return $ matches [ 1 ] ; }
Returns a array with the method annotations
2,555
public function getRole ( $ identifier ) { $ repository = $ this -> getRepository ( ) ; $ role = $ repository -> sudo ( function ( ) use ( $ repository , $ identifier ) { $ role = null ; $ roleService = $ repository -> getRoleService ( ) ; try { if ( $ identifier !== ucfirst ( $ identifier ) ) { @ trigger_error ( "'{$i...
Fetches the role with identifier
2,556
protected function getObjectManager ( $ object ) { $ namespace = '\\EzSystems\\BehatBundle\\ObjectManager\\' ; if ( empty ( $ this -> objectManagers [ $ object ] ) ) { $ class = $ namespace . $ object ; if ( ! class_exists ( $ class ) && is_subclass_of ( $ class , $ namespace . 'ObjectManagerInterface' ) ) { throw new ...
Get a specific object manager
2,557
protected function getValuesFromKeyMap ( $ key ) { if ( empty ( $ key ) || empty ( $ this -> keyMap [ $ key ] ) ) { return null ; } return $ this -> keyMap [ $ key ] ; }
Fetches values needed for testing stored on mapping
2,558
protected function changeMappedValuesOnUrl ( $ url ) { $ newUrl = "" ; foreach ( explode ( '/' , $ url ) as $ chunk ) { $ newChunk = $ this -> getValuesFromKeyMap ( $ chunk ) ; if ( empty ( $ newChunk ) ) { $ newChunk = $ chunk ; } $ newUrl .= '/' . $ newChunk ; } return preg_replace ( '/\/\//' , '/' , $ newUrl ) ; }
Change the mapped values in key map into the intended URL
2,559
protected function getCredentialsFor ( $ roleIdentifier ) { $ roleService = $ this -> getRepository ( ) -> getRoleService ( ) ; $ role = $ this -> getRepository ( ) -> sudo ( function ( ) use ( $ roleService , $ roleIdentifier ) { if ( $ roleIdentifier !== ucfirst ( $ roleIdentifier ) ) { @ trigger_error ( "'{$roleIden...
Get credentials for a specific role
2,560
public function loadUserGroup ( $ id ) { $ repository = $ this -> getRepository ( ) ; $ userService = $ repository -> getUserService ( ) ; $ userGroup = $ repository -> sudo ( function ( ) use ( $ id , $ userService ) { return $ userService -> loadUserGroup ( $ id ) ; } ) ; return $ userGroup ; }
Load a User Group by id
2,561
static function convertTableToArrayOfData ( TableNode $ table , array $ data = null ) { if ( empty ( $ data ) ) $ data = array ( ) ; $ i = 0 ; $ rows = $ table -> getRows ( ) ; $ headers = array_shift ( $ rows ) ; foreach ( $ rows as $ row ) { $ count = count ( array_filter ( $ row ) ) ; if ( $ count == 1 && count ( $ ...
This function will convert Gherkin tables into structure array of data
2,562
public function getNumberFromString ( $ string ) { preg_match ( '/(?P<digit>\d+)/' , $ string , $ result ) ; Assertion :: assertNotEmpty ( $ result [ 'digit' ] , "Expected to find a number in '$string' found none" ) ; return ( int ) $ result [ 'digit' ] ; }
Fetchs the first integer in the string
2,563
public function existTableRow ( NodeElement $ row , array $ columns , array $ columnsPositions = null ) { $ elType = $ row -> find ( 'xpath' , "/th" ) ; $ type = ( empty ( $ elType ) ) ? '/td' : '/th' ; $ max = count ( $ columns ) ; for ( $ i = 0 ; $ i < $ max ; $ i ++ ) { $ position = "" ; if ( ! empty ( $ columnsPosi...
Verifies if a row as the expected columns position of columns can be added for a more accurated assertion
2,564
static function assertSingleElement ( $ search , $ element , $ pageSection = null , $ type = 'element' ) { $ section = ( $ pageSection === null ) ? "" : " in '$pageSection' page section" ; Assertion :: assertNotEmpty ( $ element , "Couldn't find '$search' $type" . $ section ) ; Assertion :: assertEquals ( 1 , count ( $...
Assert that 1 page element was found
2,565
static function assertElementFound ( $ search , $ element , $ pageSection = null , $ type = 'element' ) { $ section = ( $ pageSection === null ) ? "" : " in '$pageSection' page section" ; Assertion :: assertNotEmpty ( $ element , "Couldn't find '$search' $type" . $ section ) ; }
Assert that at least 1 page element was found
2,566
static function assertElementNotFound ( $ search , $ element , $ pageSection = null , $ type = 'element' ) { $ section = ( $ pageSection === null ) ? "" : " in '$pageSection' page section" ; Assertion :: assertEmpty ( $ element , "Found '$search' $type" . $ section ) ; }
Assert that no page element was found
2,567
public function addProxySettings ( $ server , $ port = 3128 , $ wrapper = 'http' , $ username = null , $ password = null ) { $ settings = array ( $ wrapper => array ( 'proxy' => sprintf ( 'tcp://%s:%d' , $ server , $ port ) , 'request_fulluri' => true , ) ) ; if ( isset ( $ username ) && isset ( $ password ) ) { $ sett...
Add proxy settings to the stream context array .
2,568
public function clearProxySettings ( $ wrapper = null ) { $ wrappers = isset ( $ wrapper ) ? array ( $ wrapper ) : array_keys ( $ this -> _streamContextOptions ) ; $ clearedWrappers = array ( ) ; $ options = array ( 'proxy' , 'request_fulluri' , 'header' ) ; foreach ( $ wrappers as $ wrapper ) { if ( isset ( $ this -> ...
Clear proxy settings from the stream context options array .
2,569
protected function deduplicateCompressionPattern ( $ matches , & $ pattern ) { $ tmp_matches = $ matches ; $ first_match = array_shift ( $ tmp_matches ) ; $ differences = array ( ) ; foreach ( $ tmp_matches as $ some_match ) { $ differences += array_diff_assoc ( $ first_match , $ some_match ) ; } $ identical = array_di...
That looks complicated ...
2,570
protected function _pregUnQuote ( $ pattern , $ matches ) { $ search = array ( '\\' . self :: REGEX_DELIMITER , '\\.' , '\\\\' , '\\+' , '\\[' , '\\^' , '\\]' , '\\$' , '\\(' , '\\)' , '\\{' , '\\}' , '\\=' , '\\!' , '\\<' , '\\>' , '\\|' , '\\:' , '\\-' , '.*' , '.' , '\\?' ) ; $ replace = array ( self :: REGEX_DELIMI...
Converts preg match patterns back to browscap match patterns .
2,571
protected function _loadCache ( $ cache_file ) { require $ cache_file ; if ( ! isset ( $ cache_version ) || $ cache_version != self :: CACHE_FILE_VERSION ) { return false ; } $ this -> _source_version = $ source_version ; $ this -> _browsers = $ browsers ; $ this -> _userAgents = $ userAgents ; $ this -> _patterns = $ ...
Loads the cache into object s properties
2,572
protected function _buildCache ( ) { $ cacheTpl = "<?php\n\$source_version=%s;\n\$cache_version=%s;\n\$properties=%s;\n\$browsers=%s;\n\$userAgents=%s;\n\$patterns=%s;\n" ; $ propertiesArray = $ this -> _array2string ( $ this -> _properties ) ; $ patternsArray = $ this -> _array2string ( $ this -> _patterns ) ; $ userA...
Parses the array to cache and creates the PHP string to write to disk
2,573
protected function _getStreamContext ( $ recreate = false ) { if ( ! isset ( $ this -> _streamContext ) || true === $ recreate ) { $ this -> _streamContext = stream_context_create ( $ this -> _streamContextOptions ) ; } return $ this -> _streamContext ; }
Lazy getter for the stream context resource .
2,574
protected function _getRemoteMTime ( ) { $ remote_datetime = $ this -> _getRemoteData ( $ this -> remoteVerUrl ) ; $ remote_tmstp = strtotime ( $ remote_datetime ) ; if ( ! $ remote_tmstp ) { throw new Exception ( "Bad datetime format from {$this->remoteVerUrl}" ) ; } return $ remote_tmstp ; }
Gets the remote ini file update timestamp
2,575
protected function _array2string ( $ array ) { $ strings = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key = '' ; } elseif ( ctype_digit ( ( string ) $ key ) || '.0' === substr ( $ key , - 2 ) ) { $ key = intval ( $ key ) . '=>' ; } else { $ key = "'" . str_replace ( "'" , "\'" , $...
Converts the given array to the PHP string which represent it . This method optimizes the PHP code and the output differs form the var_export one as the internal PHP function does not strip whitespace or convert strings to numbers .
2,576
protected function _getUpdateMethod ( ) { if ( $ this -> updateMethod === null ) { if ( $ this -> localFile !== null ) { $ this -> updateMethod = self :: UPDATE_LOCAL ; } elseif ( ini_get ( 'allow_url_fopen' ) && function_exists ( 'file_get_contents' ) ) { $ this -> updateMethod = self :: UPDATE_FOPEN ; } elseif ( func...
Checks for the various possibilities offered by the current configuration of PHP to retrieve external HTTP data
2,577
protected function _getUserAgent ( ) { $ ua = str_replace ( '%v' , self :: VERSION , $ this -> userAgent ) ; $ ua = str_replace ( '%m' , $ this -> _getUpdateMethod ( ) , $ ua ) ; return $ ua ; }
Format the useragent string to be used in the remote requests made by the class during the update process .
2,578
protected function getStreamContext ( $ listen = false ) { $ options = [ ] ; if ( $ this -> scheme == Protocol :: SCHEME_UNDERLYING_SECURE || $ this -> scheme == Protocol :: SCHEME_UNDERLYING ) { $ options [ 'socket' ] = $ this -> getSocketStreamContextOptions ( ) ; } if ( $ this -> scheme == Protocol :: SCHEME_UNDERLY...
Gets a stream context
2,579
public function handlePayload ( Payload $ payload ) : void { $ app = $ this -> getClientApplication ( ) ; $ this -> logger -> debug ( 'Handling payload: ' . $ payload -> getPayload ( ) ) ; switch ( $ type = $ payload -> getType ( ) ) { case Protocol :: TYPE_TEXT : if ( method_exists ( $ app , 'onData' ) ) { $ app -> on...
Handle a complete payload received from the client
2,580
public function close ( int $ code = Protocol :: CLOSE_NORMAL , string $ reason = null ) : bool { try { if ( ! $ this -> handshaked ) { $ response = $ this -> protocol -> getResponseError ( $ code ) ; $ this -> socket -> send ( $ response ) ; } else { $ response = $ this -> protocol -> getClosePayload ( $ code , false ...
Closes the connection according to the WebSocket protocol
2,581
public function send ( string $ data , int $ type = Protocol :: TYPE_TEXT ) : bool { if ( ! $ this -> handshaked ) { throw new HandshakeException ( 'Connection is not handshaked' ) ; } $ payload = $ this -> protocol -> getPayload ( ) ; if ( ! is_scalar ( $ data ) && ! $ data instanceof Payload ) { $ data = json_encode ...
Sends the payload to the connection
2,582
public function process ( ) { $ data = $ this -> socket -> receive ( ) ; $ bytes = strlen ( $ data ) ; if ( $ bytes === 0 || $ data === false ) { throw new CloseException ( 'Error reading data from socket: ' . $ this -> socket -> getLastError ( ) ) ; } $ this -> onData ( $ data ) ; }
Processes data on the socket
2,583
public function handshake ( $ data ) { try { list ( $ path , $ origin , $ key , $ extensions , $ protocol , $ headers , $ params ) = $ this -> protocol -> validateRequestHandshake ( $ data ) ; $ this -> headers = $ headers ; $ this -> queryParams = $ params ; $ this -> application = $ this -> manager -> getApplicationF...
Performs a websocket handshake
2,584
protected function export ( $ data ) : string { $ export = '' ; foreach ( str_split ( $ data ) as $ chr ) { $ export .= '\\x' . ord ( $ chr ) ; } }
Returns a string export of the given binary data
2,585
public function onHandshakeRequest ( Connection $ connection , string $ path , string $ origin , string $ key , array $ extensions ) : void { if ( ! $ this -> isAllowed ( $ origin ) ) { $ connection -> close ( Protocol :: CLOSE_NORMAL , 'Not allowed origin during handshake request' ) ; } }
Handshake request listener Closes the connection on handshake from an origin that isn t allowed
2,586
public function isAllowed ( string $ origin ) : bool { $ scheme = parse_url ( $ origin , PHP_URL_SCHEME ) ; $ host = parse_url ( $ origin , PHP_URL_HOST ) ? : $ origin ; foreach ( $ this -> allowed as $ allowed ) { $ allowed_scheme = parse_url ( $ allowed , PHP_URL_SCHEME ) ; if ( $ allowed_scheme && $ scheme != $ allo...
Whether the specified origin is allowed under this policy
2,587
public function encode ( string $ data , int $ type = Protocol :: TYPE_TEXT , bool $ masked = false ) { $ this -> frames = [ ] ; $ frame = $ this -> getFrame ( ) ; array_push ( $ this -> frames , $ frame ) ; $ frame -> encode ( $ data , $ type , $ masked ) ; return $ this ; }
Encodes a payload
2,588
protected function getCurrentFrame ( ) { if ( empty ( $ this -> frames ) ) { array_push ( $ this -> frames , $ this -> getFrame ( ) ) ; } return end ( $ this -> frames ) ; }
Gets the current frame for the payload
2,589
public function receiveData ( string $ data ) : void { $ chunkSize = null ; while ( $ data ) { $ frame = $ this -> getReceivingFrame ( ) ; $ remaining = $ frame -> getRemainingData ( ) ; if ( $ remaining === null ) { $ chunkSize = 2 ; } elseif ( $ remaining > 0 ) { $ chunkSize = $ remaining ; } $ chunkSize = min ( strl...
Receive raw data into the payload
2,590
protected function getReceivingFrame ( ) : Frame { $ current = $ this -> getCurrentFrame ( ) ; if ( $ current -> isComplete ( ) ) { if ( $ current -> isFinal ( ) ) { throw new PayloadException ( 'Payload cannot receive data: it is already complete' ) ; } else { $ this -> frames [ ] = $ current = $ this -> getFrame ( ) ...
Gets the frame into which data should be receieved
2,591
public function getIp ( ) : string { $ name = $ this -> getName ( ) ; if ( $ name ) { return self :: getNamePart ( $ name , self :: NAME_PART_IP ) ; } else { throw new SocketException ( 'Cannot get socket IP address' ) ; } }
Gets the IP address of the socket
2,592
protected function getName ( ) : string { if ( ! isset ( $ this -> name ) || ! $ this -> name ) { $ this -> name = @ stream_socket_get_name ( $ this -> socket , true ) ; } return $ this -> name ; }
Gets the name of the socket
2,593
public function getPort ( ) : int { $ name = $ this -> getName ( ) ; if ( $ name ) { return ( int ) self :: getNamePart ( $ name , self :: NAME_PART_PORT ) ; } else { throw new SocketException ( 'Cannot get socket IP address' ) ; } }
Gets the port of the socket
2,594
public function getLastError ( ) : string { if ( $ this -> isConnected ( ) && $ this -> socket ) { $ err = @ socket_last_error ( $ this -> socket ) ; if ( $ err ) { $ err = socket_strerror ( $ err ) ; } if ( ! $ err ) { $ err = 'Unknown error' ; } return $ err ; } else { return 'Not connected' ; } }
Get the last error that occurred on the socket
2,595
public function receive ( int $ length = self :: DEFAULT_RECEIVE_LENGTH ) : string { $ buffer = '' ; $ metadata [ 'unread_bytes' ] = 0 ; $ makeBlockingAfterRead = false ; try { do { if ( ! $ this -> socket || feof ( $ this -> socket ) ) { $ this -> disconnect ( ) ; return $ buffer ; } $ result = fread ( $ this -> socke...
Receive data from the socket
2,596
public function disconnect ( ) : void { if ( $ this -> socket ) { stream_socket_shutdown ( $ this -> socket , STREAM_SHUT_RDWR ) ; } $ this -> socket = null ; $ this -> connected = false ; }
Disconnect the socket
2,597
protected function configure ( array $ options ) : void { $ options = array_merge ( [ 'timeout_socket' => self :: TIMEOUT_SOCKET , ] , $ options ) ; parent :: configure ( $ options ) ; }
Configure options Options include - timeout_socket = > int seconds default 5
2,598
public function run ( ) : void { $ this -> connectionManager -> listen ( ) ; while ( $ this -> loop -> shouldContinue ( ) ) { $ this -> connectionManager -> selectAndProcess ( ) ; foreach ( $ this -> applications as $ application ) { if ( method_exists ( $ application , 'onUpdate' ) ) { $ application -> onUpdate ( ) ; ...
Main server loop
2,599
public function notify ( $ event , array $ arguments = [ ] ) : void { if ( ! isset ( $ this -> listeners [ $ event ] ) ) { return ; } foreach ( $ this -> listeners [ $ event ] as $ listener ) { call_user_func_array ( $ listener , $ arguments ) ; } }
Notifies listeners of an event