idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
46,000
protected function runLongOperation ( $ op , $ method = 'post' , array $ body = [ ] ) { $ result = $ this -> runOperation ( $ op , $ method , $ body ) ; $ activities = $ result -> getActivities ( ) ; if ( count ( $ activities ) !== 1 ) { trigger_error ( sprintf ( "Expected one activity, found %d" , count ( $ activities...
Run a long - running operation .
46,001
public function hasProperty ( $ property , $ lazyLoad = true ) { if ( ! $ this -> isProperty ( $ property ) ) { return false ; } if ( ! array_key_exists ( $ property , $ this -> data ) && $ lazyLoad ) { $ this -> ensureFull ( ) ; } return array_key_exists ( $ property , $ this -> data ) ; }
Check whether a property exists in the resource .
46,002
public function getProperty ( $ property , $ required = true , $ lazyLoad = true ) { if ( ! $ this -> hasProperty ( $ property , $ lazyLoad ) ) { if ( $ required ) { throw new \ InvalidArgumentException ( "Property not found: $property" ) ; } return null ; } return $ this -> data [ $ property ] ; }
Get a property of the resource .
46,003
public function delete ( ) { $ data = $ this -> sendRequest ( $ this -> getUri ( ) , 'delete' ) ; return new Result ( $ data , $ this -> getUri ( ) , $ this -> client , get_called_class ( ) ) ; }
Delete the resource .
46,004
public function update ( array $ values ) { if ( $ errors = $ this -> checkUpdate ( $ values ) ) { $ message = "Cannot update resource due to validation error(s): " . implode ( '; ' , $ errors ) ; throw new \ InvalidArgumentException ( $ message ) ; } $ data = $ this -> runOperation ( 'edit' , 'patch' , $ values ) -> g...
Update the resource .
46,005
protected static function checkUpdate ( array $ values ) { $ errors = [ ] ; foreach ( $ values as $ key => $ value ) { $ errors += static :: checkProperty ( $ key , $ value ) ; } return $ errors ; }
Validate values for update .
46,006
public function refresh ( array $ options = [ ] ) { $ request = new Request ( 'get' , $ this -> getUri ( ) ) ; $ this -> setData ( self :: send ( $ request , $ this -> client , $ options ) ) ; $ this -> isFull = true ; }
Refresh the resource .
46,007
public function operationAvailable ( $ op , $ refreshDuringCheck = false ) { if ( ! $ this -> isFull ) { $ this -> refresh ( ) ; $ refreshDuringCheck = false ; } $ available = $ this -> isOperationAvailable ( $ op ) ; if ( $ available ) { return true ; } if ( $ refreshDuringCheck ) { $ this -> refresh ( ) ; $ available...
Check whether an operation is available on the resource .
46,008
public function getLink ( $ rel , $ absolute = true ) { if ( ! $ this -> hasLink ( $ rel ) ) { throw new \ InvalidArgumentException ( "Link not found: $rel" ) ; } $ url = $ this -> data [ '_links' ] [ $ rel ] [ 'href' ] ; if ( $ absolute && strpos ( $ url , '//' ) === false ) { $ url = $ this -> makeAbsoluteUrl ( $ url...
Get a link for a given resource relation .
46,009
protected function makeAbsoluteUrl ( $ relativeUrl , $ baseUrl = null ) { $ baseUrl = $ baseUrl ? : $ this -> baseUrl ; if ( empty ( $ baseUrl ) ) { throw new \ RuntimeException ( 'No base URL' ) ; } $ base = \ GuzzleHttp \ Psr7 \ uri_for ( $ baseUrl ) ; return $ base -> withPath ( $ relativeUrl ) -> __toString ( ) ; }
Make a URL absolute based on the base URL .
46,010
public function getProperties ( $ lazyLoad = true ) { if ( $ lazyLoad ) { $ this -> ensureFull ( ) ; } $ keys = $ this -> getPropertyNames ( ) ; return array_intersect_key ( $ this -> data , array_flip ( $ keys ) ) ; }
Get an array of this resource s properties and their values .
46,011
public function disable ( ) { if ( ! $ this -> getProperty ( 'is_enabled' ) ) { return new Result ( [ ] , $ this -> baseUrl , $ this -> client , get_called_class ( ) ) ; } return $ this -> update ( [ 'is_enabled' => false ] ) ; }
Disable the variable .
46,012
protected function getDefaultDirectory ( ) { $ default = $ this -> getHomeDirectory ( ) . '/.platformsh/.session' ; if ( $ this -> canWrite ( $ default ) ) { return $ default ; } $ temp = sys_get_temp_dir ( ) . '/.platformsh-client/.session' ; if ( $ this -> canWrite ( $ temp ) ) { return $ temp ; } throw new \ Runtime...
Get the default directory for session files .
46,013
protected function getHomeDirectory ( ) { $ home = getenv ( 'HOME' ) ; if ( ! $ home && ( $ userProfile = getenv ( 'USERPROFILE' ) ) ) { $ home = $ userProfile ; } if ( ! $ home || ! is_dir ( $ home ) ) { throw new \ RuntimeException ( 'Could not determine home directory' ) ; } return $ home ; }
Finds the user s home directory .
46,014
public function getSubscriptionId ( ) { if ( $ this -> hasProperty ( 'subscription_id' , false ) ) { return $ this -> getProperty ( 'subscription_id' ) ; } if ( isset ( $ this -> data [ 'subscription' ] [ 'license_uri' ] ) ) { return basename ( $ this -> data [ 'subscription' ] [ 'license_uri' ] ) ; } throw new \ Runti...
Get the subscription ID for the project .
46,015
public function getGitUrl ( ) { if ( ! $ this -> hasProperty ( 'repository' , false ) ) { $ host = parse_url ( $ this -> getUri ( ) , PHP_URL_HOST ) ; return "{$this->id}@git.{$host}:{$this->id}.git" ; } $ repository = $ this -> getProperty ( 'repository' ) ; return $ repository [ 'url' ] ; }
Get the Git URL for the project .
46,016
public function addUser ( $ user , $ role , $ byUuid = false ) { $ property = $ byUuid ? 'user' : 'email' ; $ body = [ $ property => $ user , 'role' => $ role ] ; return ProjectAccess :: create ( $ body , $ this -> getLink ( 'access' ) , $ this -> client ) ; }
Add a new user to a project .
46,017
public function addDomain ( $ name , array $ ssl = [ ] ) { $ body = [ 'name' => $ name ] ; if ( ! empty ( $ ssl ) ) { $ body [ 'ssl' ] = $ ssl ; } return Domain :: create ( $ body , $ this -> getLink ( 'domains' ) , $ this -> client ) ; }
Add a domain to the project .
46,018
public function addIntegration ( $ type , array $ data = [ ] ) { $ body = [ 'type' => $ type ] + $ data ; return Integration :: create ( $ body , $ this -> getLink ( 'integrations' ) , $ this -> client ) ; }
Add an integration to the project .
46,019
public function getActivities ( $ limit = 0 , $ type = null , $ startsAt = null ) { $ options = [ ] ; if ( $ type !== null ) { $ options [ 'query' ] [ 'type' ] = $ type ; } if ( $ startsAt !== null ) { $ options [ 'query' ] [ 'starts_at' ] = Activity :: formatStartsAt ( $ startsAt ) ; } $ activities = Activity :: getCo...
Get a list of project activities .
46,020
public function setVariable ( $ name , $ value , $ json = false , $ visibleBuild = true , $ visibleRuntime = true , $ sensitive = false ) { if ( ! is_scalar ( $ value ) ) { $ value = json_encode ( $ value ) ; $ json = true ; } $ values = [ 'value' => $ value , 'is_json' => $ json , 'visible_build' => $ visibleBuild , '...
Set a variable .
46,021
public function addCertificate ( $ certificate , $ key , array $ chain = [ ] ) { $ options = [ 'key' => $ key , 'certificate' => $ certificate , 'chain' => $ chain ] ; return Certificate :: create ( $ options , $ this -> getUri ( ) . '/certificates' , $ this -> client ) ; }
Add a certificate to the project .
46,022
public static function getProjectBaseFromUrl ( $ url ) { if ( preg_match ( '#/api/projects/([^/]+)#' , $ url , $ matches ) ) { return uri_for ( $ url ) -> withPath ( '/api/projects/' . $ matches [ 1 ] ) -> __toString ( ) ; } throw new \ RuntimeException ( 'Failed to find project ID from URL: ' . $ url ) ; }
Find the project base URL from another project resource s URL .
46,023
public function getParams ( ) { $ filters = array_filter ( $ this -> filters , function ( $ value ) { return $ value !== null ; } ) ; $ filters = array_map ( function ( $ value ) { return is_array ( $ value ) ? [ 'value' => $ value , 'operator' => 'IN' ] : $ value ; } , $ filters ) ; return count ( $ filters ) ? [ 'fil...
Get the URL query parameters .
46,024
public function getDefaultProvider ( ) { if ( isset ( $ this -> defaultProvider ) ) { return $ this -> getProvider ( $ this -> defaultProvider ) ; } $ providerLabels = array_keys ( $ this -> providers ) ; return $ this -> providers [ $ providerLabels [ 0 ] ] ; }
Returns the default provider . If no default provider is set the first one will be returned .
46,025
public function render ( array $ options = array ( ) , $ provider = null ) { if ( isset ( $ provider ) ) { $ options [ 'provider' ] = $ provider ; } $ request = $ this -> getCurrentRequest ( ) ; if ( ! isset ( $ request ) ) { throw new RuntimeException ( 'Comments rendering needs the Request.' ) ; } return $ this -> co...
Triggers comments rendering .
46,026
public function renderForContent ( ContentInfo $ contentInfo , array $ options = array ( ) , $ provider = null ) { if ( isset ( $ provider ) ) { $ options [ 'provider' ] = $ provider ; } $ request = $ this -> getCurrentRequest ( ) ; if ( ! isset ( $ request ) ) { throw new RuntimeException ( 'Comments rendering needs t...
Triggers comments rendering for a given ContentInfo object .
46,027
private function revokeTokens ( ) { $ revocations = array_filter ( [ 'refresh_token' => $ this -> session -> get ( 'refreshToken' ) , 'access_token' => $ this -> session -> get ( 'accessToken' ) , ] ) ; $ url = uri_for ( $ this -> config [ 'accounts' ] ) -> withPath ( $ this -> config [ 'revoke_url' ] ) -> __toString (...
Revokes the access and refresh tokens saved in the session .
46,028
protected function saveToken ( AccessToken $ token ) { if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] === 'access' ) { return ; } foreach ( $ token -> jsonSerialize ( ) as $ name => $ value ) { if ( isset ( $ this -> storageKeys [ $ name ] ) ) { $ this -> session -> set ( $ this -> stora...
Save an access token to the session .
46,029
protected function loadToken ( ) { if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] === 'access' ) { return new AccessToken ( [ 'access_token' => $ this -> config [ 'api_token' ] , 'expires' => 2147483647 , ] ) ; } if ( ! $ this -> session -> get ( $ this -> storageKeys [ 'access_token' ] ...
Load the current access token .
46,030
protected function getOauthMiddleware ( ) { if ( ! $ this -> oauthMiddleware ) { if ( ! $ this -> isLoggedIn ( ) ) { throw new \ RuntimeException ( 'Not logged in' ) ; } $ grant = new ClientCredentials ( ) ; $ grantOptions = [ ] ; if ( $ this -> config [ 'api_token' ] && $ this -> config [ 'api_token_type' ] !== 'acces...
Get an OAuth2 middleware to add to Guzzle clients .
46,031
protected function doRender ( array $ options ) { $ template = isset ( $ options [ 'template' ] ) ? $ options [ 'template' ] : $ this -> getDefaultTemplate ( ) ; unset ( $ options [ 'template' ] ) ; return $ this -> templateEngine -> render ( $ template , $ options ) ; }
Renders the template with provided options . template option allows to override the default template for rendering .
46,032
public static function fromData ( array $ data ) { $ policies = [ ] ; foreach ( isset ( $ data [ 'schedule' ] ) ? $ data [ 'schedule' ] : [ ] as $ policyData ) { $ policies [ ] = new Policy ( $ policyData [ 'interval' ] , $ policyData [ 'count' ] ) ; } return new static ( $ policies , isset ( $ data [ 'manual_count' ] ...
Instantiates a backup configuration object from config data .
46,033
public static function array_flatten ( array $ array ) { $ index = 0 ; $ count = count ( $ array ) ; while ( $ index < $ count ) { if ( is_array ( $ array [ $ index ] ) ) { array_splice ( $ array , $ index , 1 , $ array [ $ index ] ) ; } else { ++ $ index ; } $ count = count ( $ array ) ; } return $ array ; }
Make multidimensional array flat
46,034
public static function array_delete ( array & $ data , $ key ) { if ( array_key_exists ( $ key , $ data ) ) { $ value = $ data [ $ key ] ; unset ( $ data [ $ key ] ) ; return $ value ; } }
Deletes entry from array and return its value
46,035
public function getCurrentDeployment ( ) { $ deployment = EnvironmentDeployment :: get ( 'current' , $ this -> getUri ( ) . '/deployments' , $ this -> client ) ; if ( ! $ deployment ) { throw new EnvironmentStateException ( 'Current deployment not found' , $ this ) ; } return $ deployment ; }
Get the current deployment of this environment .
46,036
public function getHeadCommit ( ) { $ base = Project :: getProjectBaseFromUrl ( $ this -> getUri ( ) ) . '/git/commits' ; return Commit :: get ( $ this -> head_commit , $ base , $ this -> client ) ; }
Get the Git commit for the HEAD of this environment .
46,037
public function getSshUrl ( $ app = '' ) { $ urls = $ this -> getSshUrls ( ) ; if ( isset ( $ urls [ $ app ] ) ) { return $ urls [ $ app ] ; } return $ this -> constructLegacySshUrl ( $ app ) ; }
Get the SSH URL for the environment .
46,038
private function constructLegacySshUrl ( ) { if ( ! $ this -> hasLink ( 'ssh' ) ) { $ id = $ this -> data [ 'id' ] ; if ( ! $ this -> isActive ( ) ) { throw new EnvironmentStateException ( "No SSH URL found for environment '$id'. It is not currently active." , $ this ) ; } throw new OperationUnavailableException ( "No ...
Get the SSH URL via the legacy ssh link .
46,039
public function getSshUrls ( ) { $ prefix = 'pf:ssh:' ; $ prefixLength = strlen ( $ prefix ) ; $ sshUrls = [ ] ; foreach ( $ this -> data [ '_links' ] as $ rel => $ link ) { if ( strpos ( $ rel , $ prefix ) === 0 && isset ( $ link [ 'href' ] ) ) { $ sshUrls [ substr ( $ rel , $ prefixLength ) ] = $ this -> convertSshUr...
Returns a list of SSH URLs keyed by app name .
46,040
public function getPublicUrl ( ) { if ( ! $ this -> hasLink ( 'public-url' ) ) { $ id = $ this -> data [ 'id' ] ; if ( ! $ this -> isActive ( ) ) { throw new EnvironmentStateException ( "No public URL found for environment '$id'. It is not currently active." , $ this ) ; } throw new OperationUnavailableException ( "No ...
Get the public URL for the environment .
46,041
public function synchronize ( $ data = false , $ code = false , $ rebase = false ) { if ( ! $ data && ! $ code ) { throw new \ InvalidArgumentException ( 'Nothing to synchronize: you must specify $data or $code' ) ; } $ body = [ 'synchronize_data' => $ data , 'synchronize_code' => $ code , ] ; if ( $ rebase ) { $ body ...
Synchronize an environment with its parent .
46,042
public function setVariable ( $ name , $ value , $ json = false , $ enabled = true , $ sensitive = false ) { if ( ! is_scalar ( $ value ) ) { $ value = json_encode ( $ value ) ; $ json = true ; } $ values = [ 'value' => $ value , 'is_json' => $ json , 'is_enabled' => $ enabled ] ; if ( $ sensitive ) { $ values [ 'is_se...
Set a variable
46,043
public function getRouteUrls ( ) { $ routes = [ ] ; if ( isset ( $ this -> data [ '_links' ] [ 'pf:routes' ] ) ) { foreach ( $ this -> data [ '_links' ] [ 'pf:routes' ] as $ route ) { $ routes [ ] = $ route [ 'href' ] ; } } return $ routes ; }
Get the resolved URLs for the environment s routes .
46,044
public function addUser ( $ user , $ role , $ byUuid = true ) { $ property = $ byUuid ? 'user' : 'email' ; $ body = [ $ property => $ user , 'role' => $ role ] ; return EnvironmentAccess :: create ( $ body , $ this -> getLink ( '#manage-access' ) , $ this -> client ) ; }
Add a new user to the environment .
46,045
public function addBackupPolicy ( Policy $ policy ) { $ backups = isset ( $ this -> data [ 'backups' ] ) ? $ this -> data [ 'backups' ] : [ ] ; $ backups [ 'schedule' ] [ ] = [ 'interval' => $ policy -> getInterval ( ) , 'count' => $ policy -> getCount ( ) , ] ; if ( ! isset ( $ backups [ 'manual_count' ] ) ) { $ backu...
Add a scheduled backup policy .
46,046
public static function parameterize ( $ string , $ sep = '-' ) { $ parameterized_string = static :: transliterate ( $ string ) ; $ parameterized_string = preg_replace ( '/[^a-z0-9\-_]+/i' , $ sep , $ parameterized_string ) ; if ( ! ( is_null ( $ sep ) || empty ( $ sep ) ) ) { $ re_sep = preg_quote ( $ sep ) ; $ paramet...
Replaces special characters in a string so that it may be used as part of a pretty URL .
46,047
public function getProject ( $ id , $ hostname = null , $ https = true ) { foreach ( $ this -> getProjects ( ) as $ project ) { if ( $ project -> id === $ id ) { return $ project ; } } if ( $ hostname !== null ) { return $ this -> getProjectDirect ( $ id , $ hostname , $ https ) ; } if ( $ url = $ this -> locateProject...
Get a single project by its ID .
46,048
public function getProjects ( $ reset = false ) { $ data = $ this -> getAccountInfo ( $ reset ) ; $ client = $ this -> connector -> getClient ( ) ; $ projects = [ ] ; foreach ( $ data [ 'projects' ] as $ project ) { $ projects [ ] = new Project ( $ project , $ project [ 'endpoint' ] , $ client ) ; } return $ projects ;...
Get the logged - in user s projects .
46,049
public function getAccountInfo ( $ reset = false ) { if ( ! isset ( $ this -> accountInfo ) || $ reset ) { $ url = $ this -> accountsEndpoint . 'me' ; try { $ this -> accountInfo = $ this -> simpleGet ( $ url ) ; } catch ( BadResponseException $ e ) { throw ApiResponseException :: create ( $ e -> getRequest ( ) , $ e -...
Get account information for the logged - in user .
46,050
private function simpleGet ( $ url , array $ options = [ ] ) { return ( array ) \ GuzzleHttp \ json_decode ( $ this -> getConnector ( ) -> getClient ( ) -> request ( 'get' , $ url , $ options ) -> getBody ( ) -> getContents ( ) , true ) ; }
Get a URL and return the JSON - decoded response .
46,051
public function getProjectDirect ( $ id , $ hostname , $ https = true ) { $ scheme = $ https ? 'https' : 'http' ; $ collection = "$scheme://$hostname/api/projects" ; return Project :: get ( $ id , $ collection , $ this -> connector -> getClient ( ) ) ; }
Get a single project at a known location .
46,052
protected function locateProject ( $ id ) { $ url = $ this -> accountsEndpoint . 'projects/' . rawurlencode ( $ id ) ; try { $ result = $ this -> simpleGet ( $ url ) ; } catch ( BadResponseException $ e ) { $ response = $ e -> getResponse ( ) ; $ ignoredErrorCodes = [ 400 , 403 , 404 ] ; if ( $ response && in_array ( $...
Locate a project by ID .
46,053
public function getSshKeys ( $ reset = false ) { $ data = $ this -> getAccountInfo ( $ reset ) ; return SshKey :: wrapCollection ( $ data [ 'ssh_keys' ] , $ this -> accountsEndpoint , $ this -> connector -> getClient ( ) ) ; }
Get the logged - in user s SSH keys .
46,054
public function getSshKey ( $ id ) { $ url = $ this -> accountsEndpoint . 'ssh_keys' ; return SshKey :: get ( $ id , $ url , $ this -> connector -> getClient ( ) ) ; }
Get a single SSH key by its ID .
46,055
public function addSshKey ( $ value , $ title = null ) { $ values = $ this -> cleanRequest ( [ 'value' => $ value , 'title' => $ title ] ) ; $ url = $ this -> accountsEndpoint . 'ssh_keys' ; return SshKey :: create ( $ values , $ url , $ this -> connector -> getClient ( ) ) ; }
Add an SSH public key to the logged - in user s account .
46,056
public function createSubscription ( $ region , $ plan = 'development' , $ title = null , $ storage = null , $ environments = null , array $ activationCallback = null ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; $ values = $ this -> cleanRequest ( [ 'project_region' => $ region , 'plan' => $ plan , 'proje...
Create a new Platform . sh subscription .
46,057
public function getSubscriptions ( ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; return Subscription :: getCollection ( $ url , 0 , [ ] , $ this -> connector -> getClient ( ) ) ; }
Get a list of your Platform . sh subscriptions .
46,058
public function getSubscription ( $ id ) { $ url = $ this -> accountsEndpoint . 'subscriptions' ; return Subscription :: get ( $ id , $ url , $ this -> connector -> getClient ( ) ) ; }
Get a subscription by its ID .
46,059
public function getSubscriptionEstimate ( $ plan , $ storage , $ environments , $ users ) { $ options = [ ] ; $ options [ 'query' ] = [ 'plan' => $ plan , 'storage' => $ storage , 'environments' => $ environments , 'user_licenses' => $ users , ] ; try { return $ this -> simpleGet ( $ this -> accountsEndpoint . 'estimat...
Estimate the cost of a subscription .
46,060
public function getPlanRecords ( PlanRecordQuery $ query = null ) { $ url = $ this -> accountsEndpoint . 'records/plan' ; $ options = [ ] ; if ( $ query ) { $ options [ 'query' ] = $ query -> getParams ( ) ; } return PlanRecord :: getCollection ( $ url , 0 , $ options , $ this -> connector -> getClient ( ) ) ; }
Get plan records .
46,061
public function acronym ( $ word ) { $ this -> acronyms [ strtolower ( $ word ) ] = $ word ; $ this -> acronym_regex = implode ( '|' , $ this -> acronyms ) ; }
Specifies a new acronym . An acronym must be specified as it will appear in a camelized string . An underscore string that contains the acronym will retain the acronym when passed to camelize humanize or titleize . A camelized string that contains the acronym will maintain the acronym when titleized or humanized and wi...
46,062
public function plural ( $ rule , $ replacement ) { if ( is_string ( $ rule ) ) { Utils :: array_delete ( $ this -> uncountables , $ rule ) ; } Utils :: array_delete ( $ this -> uncountables , $ replacement ) ; array_unshift ( $ this -> plurals , array ( $ rule , $ replacement ) ) ; }
Specifies a new pluralization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .
46,063
public function singular ( $ rule , $ replacement ) { if ( is_string ( $ rule ) ) { Utils :: array_delete ( $ this -> uncountables , $ rule ) ; } Utils :: array_delete ( $ this -> uncountables , $ replacement ) ; array_unshift ( $ this -> singulars , array ( $ rule , $ replacement ) ) ; }
Specifies a new singularization rule and its replacement . The rule can either be a string or a regular expression . The replacement should always be a string that may include references to the matched data from the rule .
46,064
public function irregular ( $ singular , $ plural ) { Utils :: array_delete ( $ this -> uncountables , $ singular ) ; Utils :: array_delete ( $ this -> uncountables , $ plural ) ; $ singular_char = substr ( $ singular , 0 , 1 ) ; $ singular_char_upcase = strtoupper ( substr ( $ singular , 0 , 1 ) ) ; $ singular_char_do...
Specifies a new irregular that applies to both pluralization and singularization at the same time . This can only be used for strings not regular expressions . You simply pass the irregular in singular and plural form .
46,065
public function uncountable ( ) { $ words = func_get_args ( ) ; array_push ( $ this -> uncountables , $ words ) ; $ this -> uncountables = Utils :: array_flatten ( $ this -> uncountables ) ; return $ this -> uncountables ; }
Add uncountable words that shouldn t be attempted inflected .
46,066
public static function getErrorDetails ( ResponseInterface $ response ) { $ responseInfoProperties = [ 'message' , 'detail' , 'title' , 'type' , 'error' , 'error_description' , ] ; $ details = '' ; $ response -> getBody ( ) -> seek ( 0 ) ; $ contents = $ response -> getBody ( ) -> getContents ( ) ; try { $ json = \ Guz...
Get more details from the response body to add to error messages .
46,067
public static function fromName ( $ refName , Project $ project , ClientInterface $ client ) { $ url = $ project -> getUri ( ) . '/git/refs' ; return static :: get ( $ refName , $ url , $ client ) ; }
Get a Ref object in a project .
46,068
public function getCommit ( ) { $ data = $ this -> object ; if ( $ data [ 'type' ] !== 'commit' ) { throw new \ RuntimeException ( 'This ref is not a commit' ) ; } $ url = Project :: getProjectBaseFromUrl ( $ this -> getUri ( ) ) . '/git/commits' ; return Commit :: get ( $ data [ 'sha' ] , $ url , $ this -> client ) ; ...
Get the commit for this ref .
46,069
public function wait ( callable $ onPoll = null , $ interval = 2 ) { while ( $ this -> isPending ( ) ) { sleep ( $ interval > 1 ? $ interval : 1 ) ; $ this -> refresh ( ) ; if ( $ onPoll !== null ) { $ onPoll ( $ this ) ; } } }
Wait for the subscription s project to be provisioned .
46,070
public function getOwner ( ) { $ uuid = $ this -> getProperty ( 'owner' ) ; $ url = $ this -> makeAbsoluteUrl ( '/api/users' , $ this -> getLink ( 'project' ) ) ; return Account :: get ( $ uuid , $ url , $ this -> client ) ; }
Get the account for the project s owner .
46,071
public function getProject ( ) { if ( ! $ this -> hasLink ( 'project' ) && ! $ this -> isActive ( ) ) { throw new \ BadMethodCallException ( 'Inactive subscriptions do not have projects.' ) ; } $ url = $ this -> getLink ( 'project' ) ; return Project :: get ( $ url , null , $ this -> client ) ; }
Get the project associated with this subscription .
46,072
public function wait ( callable $ onPoll = null , callable $ onLog = null , $ pollInterval = 1 ) { $ log = $ this -> getProperty ( 'log' ) ; if ( $ onLog !== null && strlen ( trim ( $ log ) ) ) { $ onLog ( trim ( $ log ) . "\n" ) ; } $ length = strlen ( $ log ) ; $ retries = 0 ; while ( ! $ this -> isComplete ( ) ) { u...
Wait for the activity to complete .
46,073
public function restore ( $ target = null , $ branchFrom = null ) { if ( $ this -> getProperty ( 'type' ) !== 'environment.backup' ) { throw new \ BadMethodCallException ( 'Cannot restore activity (wrong type)' ) ; } if ( ! $ this -> isComplete ( ) ) { throw new \ BadMethodCallException ( 'Cannot restore backup (not co...
Restore the backup associated with this activity .
46,074
public function getDescription ( $ html = false ) { $ description = $ this -> getProperty ( 'description' ) ; if ( $ html ) { return $ description ; } return html_entity_decode ( strip_tags ( $ description ) , ENT_QUOTES , 'utf-8' ) ; }
Get a human - readable description of the activity .
46,075
public static function inflections ( $ block = false ) { if ( $ block ) { return call_user_func ( $ block , Inflections :: instance ( ) ) ; } else { return Inflections :: instance ( ) ; } }
Yields a singleton instance of Inflections so you can specify additional inflector rules .
46,076
private static function stringToSeconds ( $ duration ) { if ( isset ( self :: $ suffixes [ substr ( $ duration , - 1 ) ] ) ) { $ amount = substr ( $ duration , 0 , strlen ( $ duration ) - 1 ) ; $ unit = self :: $ suffixes [ substr ( $ duration , - 1 ) ] ; } else { $ unit = 1 ; $ amount = $ duration ; } if ( ! is_numeri...
Converts a duration string to seconds .
46,077
public function getAccount ( ) { $ uuid = $ this -> getProperty ( 'id' ) ; $ url = $ this -> makeAbsoluteUrl ( '/api/users' ) ; $ account = Account :: get ( $ uuid , $ url , $ this -> client ) ; if ( ! $ account ) { throw new \ Exception ( "Account not found for user: " . $ uuid ) ; } return $ account ; }
Get the account information for this user .
46,078
public function getEnvironmentRole ( Environment $ environment ) { $ access = $ environment -> getUser ( $ this -> id ) ; return $ access ? $ access -> role : false ; }
Get the user s role on an environment .
46,079
public function changeEnvironmentRole ( Environment $ environment , $ newRole ) { $ access = $ environment -> getUser ( $ this -> id ) ; if ( $ access ) { if ( $ access -> role === $ newRole ) { throw new \ InvalidArgumentException ( "There is nothing to change" ) ; } return $ access -> update ( [ 'role' => $ newRole ]...
Change the user s environment - level role .
46,080
public function signData ( $ data , PrivateKey $ privateKey , $ algorithm = OPENSSL_ALGO_SHA256 , $ format = self :: FORMAT_DER ) { Assert :: oneOf ( $ format , [ self :: FORMAT_ECDSA , self :: FORMAT_DER ] , 'The format %s to sign request does not exists. Available format: %s' ) ; $ resource = $ privateKey -> getResou...
Generate a signature of the given data using a private key and an algorithm .
46,081
private function DERtoECDSA ( $ der , $ partLength ) { $ hex = unpack ( 'H*' , $ der ) [ 1 ] ; if ( '30' !== mb_substr ( $ hex , 0 , 2 , '8bit' ) ) { throw new DataSigningException ( 'Invalid signature provided' ) ; } if ( '81' === mb_substr ( $ hex , 2 , 2 , '8bit' ) ) { $ hex = mb_substr ( $ hex , 6 , null , '8bit' )...
Convert a DER signature into ECDSA .
46,082
public function signCertificateRequest ( CertificateRequest $ certificateRequest ) { $ csrObject = $ this -> createCsrWithSANsObject ( $ certificateRequest ) ; if ( ! $ csrObject || ! openssl_csr_export ( $ csrObject , $ csrExport ) ) { throw new CSRSigningException ( sprintf ( 'OpenSSL CSR signing failed with error: %...
Generate a CSR from the given distinguishedName and keyPair .
46,083
protected function createCsrWithSANsObject ( CertificateRequest $ certificateRequest ) { $ sslConfigTemplate = <<<'EOL'[ req ]distinguished_name = req_distinguished_namereq_extensions = v3_req[ req_distinguished_name ][ v3_req ]basicConstraints = CA:FALSEkeyUsage = nonRepudiation, digitalSignature, keyEnciphermentsubj...
Generate a CSR object with SANs from the given distinguishedName and keyPair .
46,084
private function getCSRPayload ( DistinguishedName $ distinguishedName ) { $ payload = [ ] ; if ( null !== $ countryName = $ distinguishedName -> getCountryName ( ) ) { $ payload [ 'countryName' ] = $ countryName ; } if ( null !== $ stateOrProvinceName = $ distinguishedName -> getStateOrProvinceName ( ) ) { $ payload [...
Retrieves a CSR payload from the given distinguished name .
46,085
public function generateKeyPair ( $ keyOption = null ) { if ( null === $ keyOption ) { $ keyOption = new RsaKeyOption ( ) ; } if ( \ is_int ( $ keyOption ) ) { @ trigger_error ( 'Passing a keySize to "generateKeyPair" is deprecated since version 1.1 and will be removed in 2.0. Pass an instance of KeyOption instead' , E...
Generate KeyPair .
46,086
public function parse ( Key $ key ) { try { $ resource = $ key -> getResource ( ) ; } catch ( KeyFormatException $ e ) { throw new KeyParsingException ( 'Fail to load resource for key' , 0 , $ e ) ; } $ rawData = openssl_pkey_get_details ( $ resource ) ; openssl_free_key ( $ resource ) ; if ( ! \ is_array ( $ rawData )...
Parse the key .
46,087
public function parse ( Certificate $ certificate ) { $ rawData = openssl_x509_parse ( $ certificate -> getPEM ( ) ) ; if ( ! \ is_array ( $ rawData ) ) { throw new CertificateParsingException ( sprintf ( 'Fail to parse certificate with error: %s' , openssl_error_string ( ) ) ) ; } if ( ! isset ( $ rawData [ 'subject' ...
Parse the certificate .
46,088
public function onWsdlResponse ( WsdlResponseEvent $ event ) { $ xpath = new \ DOMXPath ( $ event -> getWsdl ( ) ) ; $ xpath -> registerNamespace ( 'wsaw' , self :: NS_WSAW ) ; if ( $ xpath -> query ( '//wsaw:Addressing' ) -> length || $ xpath -> query ( '//wsaw:UsingAddressing' ) -> length ) { $ this -> wsaEnabled = t...
Parse the WSDL to check if WS - Addressing should be enabled
46,089
public function onRequest ( RequestEvent $ event ) { if ( ! $ this -> wsaEnabled ) { return ; } $ request = $ event -> getRequest ( ) ; $ envelope = $ request -> documentElement ; $ soapNS = $ envelope -> namespaceURI ; $ xpath = new \ DOMXPath ( $ event -> getRequest ( ) ) ; $ xpath -> registerNamespace ( 'soap' , $ s...
Add WS - Addressing headers to the request
46,090
public function enableTotp ( Request $ request , Google2FA $ totpProvider ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; if ( ! $ secret = array_get ( $ twoFactor , 'totp.secret' ) ) { $ twoFactor [ 'totp' ] = [ 'enabled' => false , 'secret' => $ sec...
Enable TwoFactor TOTP authentication .
46,091
public function updateTotp ( AccountTwoFactorTotpProcessRequest $ request , Google2FA $ totpProvider ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ secret = array_get ( $ twoFactor , 'totp.secret' ) ; $ backup = array_get ( $ twoFactor , 'totp.back...
Process the TwoFactor TOTP enable form .
46,092
public function backupTotp ( AccountTwoFactorTotpBackupRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'totp' ] [ 'backup' ] = $ this -> generateTotpBackups ( ) ; $ twoFactor [ 'totp' ] [ 'backup_at' ] = now ( ) -> toDa...
Process the TwoFactor OTP backup .
46,093
public function enablePhone ( AccountTwoFactorPhoneRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> routeNotificationForAuthy ( ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'phone' ] [ 'enabled' ] = true ; $ currentUser -> fill ( [ 'two_factor'...
Enable TwoFactor Phone authentication .
46,094
public function disablePhone ( Request $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'phone' ] [ 'enabled' ] = false ; $ currentUser -> fill ( [ 'two_factor' => $ twoFactor ] ) -> forceSave ( ) ; return intend ( [ 'back' => t...
Disable TwoFactor Phone authentication .
46,095
protected function generateTotpBackups ( ) : array { $ backup = [ ] ; for ( $ x = 0 ; $ x <= 9 ; $ x ++ ) { $ backup [ ] = str_pad ( ( string ) random_int ( 0 , 9999999999 ) , 10 , '0' , STR_PAD_BOTH ) ; } return $ backup ; }
Generate TwoFactor OTP backup codes .
46,096
public function encodeDecimal ( $ integer , $ options ) { if ( $ integer === 1 << ( \ PHP_INT_SIZE * 8 - 1 ) ) { return sprintf ( '(int)%s%d' , $ options [ 'whitespace' ] ? ' ' : '' , $ integer ) ; } return var_export ( $ integer , true ) ; }
Encodes an integer into decimal representation .
46,097
public function encodeHexadecimal ( $ integer , $ options ) { if ( $ options [ 'hex.capitalize' ] ) { return sprintf ( '%s0x%X' , $ this -> sign ( $ integer ) , abs ( $ integer ) ) ; } return sprintf ( '%s0x%x' , $ this -> sign ( $ integer ) , abs ( $ integer ) ) ; }
Encodes an integer into hexadecimal representation .
46,098
public function getCulture ( $ culture = null ) : ? array { return $ this -> getCultures ( ) [ $ culture ] ?? ( ! empty ( $ this -> getCultures ( ) ) ? current ( $ this -> getCultures ( ) ) : null ) ; }
Get the given culture .
46,099
public function divider ( int $ order = null , array $ attributes = [ ] ) : MenuItem { return $ this -> add ( [ 'type' => 'divider' , 'order' => $ order , 'attributes' => $ attributes ] ) ; }
Add new divider item .