idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
51,000
public function hasPermissionForUser ( $ user , ... $ permission ) { $ params = [ ] ; $ params [ ] = $ user ; foreach ( $ permission as $ perm ) { $ params [ ] = $ perm ; } return $ this -> hasPolicy ( $ params ) ; }
determines whether a user has a permission .
51,001
public function savePolicy ( $ model ) { if ( '' == $ this -> filePath ) { throw new CasbinException ( 'invalid file path, file path cannot be empty' ) ; } $ writeString = '' ; if ( isset ( $ model -> model [ 'p' ] ) ) { foreach ( $ model -> model [ 'p' ] as $ ptype => $ ast ) { foreach ( $ ast -> policy as $ rule ) { ...
saves all policy rules to the storage .
51,002
public function addDef ( $ sec , $ key , $ value ) { if ( '' == $ value ) { return ; } $ ast = new Assertion ( ) ; $ ast -> key = $ key ; $ ast -> value = $ value ; if ( 'r' == $ sec || 'p' == $ sec ) { $ ast -> tokens = explode ( ', ' , $ ast -> value ) ; foreach ( $ ast -> tokens as $ i => $ token ) { $ ast -> tokens...
adds an assertion to the model .
51,003
public function loadModel ( $ path ) { $ cfg = Config :: newConfig ( $ path ) ; $ this -> loadSection ( $ cfg , 'r' ) ; $ this -> loadSection ( $ cfg , 'p' ) ; $ this -> loadSection ( $ cfg , 'e' ) ; $ this -> loadSection ( $ cfg , 'm' ) ; $ this -> loadSection ( $ cfg , 'g' ) ; }
loads the model from model CONF file .
51,004
public function loadModelFromText ( $ text ) { $ cfg = Config :: newConfigFromText ( $ text ) ; $ this -> loadSection ( $ cfg , 'r' ) ; $ this -> loadSection ( $ cfg , 'p' ) ; $ this -> loadSection ( $ cfg , 'e' ) ; $ this -> loadSection ( $ cfg , 'm' ) ; $ this -> loadSection ( $ cfg , 'g' ) ; }
loads the model from the text .
51,005
public function printModel ( ) { Log :: logPrint ( 'Model:' ) ; foreach ( $ this -> model as $ k => $ v ) { foreach ( $ v as $ i => $ j ) { Log :: logPrintf ( '%s.%s: %s' , $ k , $ i , $ j -> value ) ; } } }
prints the model to the log .
51,006
public function modulelist ( string $ roleName = '' ) : AnsibleGalaxyInterface { $ this -> addBaseoption ( 'list' ) ; if ( '' !== $ roleName ) { $ this -> addBaseoption ( $ roleName ) ; } return $ this ; }
Get a list of installed modules .
51,007
protected function prepareArguments ( bool $ asArray = true ) { $ arguments = array_merge ( [ $ this -> getBaseOptions ( ) ] , $ this -> getOptions ( ) , $ this -> getParameters ( ) ) ; if ( false === $ asArray ) { $ arguments = implode ( ' ' , $ arguments ) ; } return $ arguments ; }
Get parameter string which will be used to call ansible .
51,008
protected function addOption ( string $ name , string $ value ) : void { $ this -> options [ $ name ] = $ value ; }
Add an Option .
51,009
protected function getOptions ( ) : array { $ options = [ ] ; foreach ( $ this -> options as $ name => $ value ) { $ options [ ] = $ name . '=' . $ value ; } return $ options ; }
Get all options as array .
51,010
protected function checkParam ( $ param , string $ glue = ' ' ) : string { if ( is_array ( $ param ) ) { $ param = implode ( $ glue , $ param ) ; } return $ param ; }
Check if param is array or string and implode with glue if necessary .
51,011
protected function runProcess ( $ callback = null ) { $ process = $ this -> processBuilder -> setArguments ( $ this -> prepareArguments ( ) ) -> getProcess ( ) ; $ result = $ process -> run ( $ callback ) ; if ( null === $ callback ) { $ result = $ process -> getOutput ( ) ; if ( false === $ process -> isSuccessful ( )...
Creates process with processBuilder builder and executes it .
51,012
public function limit ( $ subset = '' ) : AnsiblePlaybookInterface { $ subset = $ this -> checkParam ( $ subset , ',' ) ; $ this -> addOption ( '--limit' , $ subset ) ; return $ this ; }
Further limit selected hosts to an additional pattern .
51,013
public function tags ( $ tags ) : AnsiblePlaybookInterface { $ tags = $ this -> checkParam ( $ tags , ',' ) ; $ this -> addOption ( '--tags' , $ tags ) ; return $ this ; }
Only run plays and tasks tagged with these values .
51,014
private function checkInventory ( ) : void { if ( ! $ this -> hasInventory ) { $ inventory = str_replace ( '.yml' , '' , $ this -> getBaseOptions ( ) ) ; $ this -> inventoryFile ( $ inventory ) ; } }
If no inventory file is given assume
51,015
public function hasListeners ( $ eventName = null ) { return ( $ this -> symfonyDispatcher -> hasListeners ( $ eventName ) || $ this -> laravelDispatcher -> hasListeners ( $ eventName ) ) ; }
Checks whether an event has any registered listeners .
51,016
private function getDefaultSortable ( ) { if ( config ( 'columnsortable.default_first_column' , false ) ) { $ sortBy = array_first ( $ this -> sortable ) ; if ( ! is_null ( $ sortBy ) ) { return [ $ sortBy => config ( 'columnsortable.default_direction' , 'asc' ) ] ; } } return null ; }
Returns the first element of defined sortable columns from the Model
51,017
private static function getAnchorClass ( $ sortColumn , & $ anchorAttributes = [ ] ) { $ class = [ ] ; $ anchorClass = config ( 'columnsortable.anchor_class' , null ) ; if ( $ anchorClass !== null ) { $ class [ ] = $ anchorClass ; } $ activeClass = config ( 'columnsortable.active_anchor_class' , null ) ; if ( $ activeC...
Take care of special case when class is passed to the sortablelink .
51,018
public function info_upload ( ) { $ this -> check ( ) ; return [ 'size_upload' => $ this -> response ( ) -> size_upload ( ) , 'upload_content' => $ this -> response ( ) -> upload_content_length ( ) , 'speed_upload' => $ this -> response ( ) -> speed_upload ( ) , 'time_request' => $ this -> response ( ) -> total_time ( ...
Return size_upload upload_content speed_upload time_request
51,019
public function info ( ) { $ this -> check ( ) ; return [ 'starttransfer_time' => $ this -> response ( ) -> starttransfer_time ( ) , 'size_download' => $ this -> response ( ) -> size_download ( ) , 'speed_download' => $ this -> response ( ) -> speed_download ( ) , 'size_upload' => $ this -> response ( ) -> size_upload ...
Return size_upload upload_content speed_upload time_request starttransfer_time size_download speed_download
51,020
public function setSimultaneousLimit ( $ count ) { if ( ! is_int ( $ count ) || $ count < 2 ) { throw new \ InvalidArgumentException ( "setSimultaneousLimit count must be an int >= 2" ) ; } $ this -> simultaneousLimit = $ count ; return $ this ; }
Set the limit for how many cURL requests will be execute simultaneously .
51,021
private function isReplicasWork ( $ replicas ) { $ ok = true ; if ( ! is_array ( $ replicas ) ) { return false ; } foreach ( $ replicas as $ replica ) { if ( $ replica [ 'is_readonly' ] ) { $ ok = false ; $ this -> error [ ] = 'is_readonly : ' . json_encode ( $ replica ) ; } if ( $ replica [ 'is_session_expired' ] ) { ...
Check the status of the cluster the request is taken from the documentation for CH total_replicas <2 - not suitable for no replication clusters
51,022
public function getTables ( $ resultDetail = false ) { $ this -> connect ( ) ; $ list = [ ] ; foreach ( $ this -> tables as $ db_name => $ tables ) { foreach ( $ tables as $ table_name => $ nodes ) { if ( $ resultDetail ) { $ list [ $ db_name . '.' . $ table_name ] = $ nodes ; } else { $ list [ $ db_name . '.' . $ tabl...
list all tables on all nodes
51,023
public function getSizeTable ( $ database_table ) { $ nodes = $ this -> getNodesByTable ( $ database_table ) ; foreach ( $ nodes as $ node ) { if ( empty ( $ this -> _table_size_cache [ $ node ] ) ) { $ this -> _table_size_cache [ $ node ] = $ this -> client ( $ node ) -> tablesSize ( true ) ; } } $ sizes = [ ] ; forea...
Table size on cluster
51,024
public function truncateTable ( $ database_table , $ timeOut = 2000 ) { $ out = [ ] ; list ( $ db , $ table ) = explode ( '.' , $ database_table ) ; $ nodes = $ this -> getMasterNodeForTable ( $ database_table ) ; foreach ( $ nodes as $ node ) { $ def = $ this -> client ( $ node ) -> getTimeout ( ) ; $ this -> client (...
Truncate on all nodes
51,025
public function setReadOnlyUser ( bool $ flag ) { $ this -> connectUserReadonly = $ flag ; $ this -> settings ( ) -> setReadOnlyUser ( $ this -> connectUserReadonly ) ; }
if the user has only read in the config file
51,026
public function enableLogQueries ( bool $ flag = true ) { $ this -> settings ( ) -> set ( 'log_queries' , ( int ) $ flag ) ; return $ this ; }
Write to system . query_log
51,027
public function enableExtremes ( bool $ flag = true ) { $ this -> settings ( ) -> set ( 'extremes' , ( int ) $ flag ) ; return $ this ; }
Read extremes of the result columns . They can be output in JSON - formats .
51,028
public function insertBatchTSVFiles ( string $ tableName , $ fileNames , array $ columns = [ ] ) { return $ this -> insertBatchFiles ( $ tableName , $ fileNames , $ columns , 'TabSeparated' ) ; }
insert TabSeparated files
51,029
public function insertBatchFiles ( string $ tableName , $ fileNames , array $ columns = [ ] , string $ format = 'CSV' ) { if ( is_string ( $ fileNames ) ) { $ fileNames = [ $ fileNames ] ; } if ( $ this -> getCountPendingQueue ( ) > 0 ) { throw new QueryException ( 'Queue must be empty, before insertBatch, need execute...
insert Batch Files
51,030
public function insertBatchStream ( string $ tableName , array $ columns = [ ] , string $ format = 'CSV' ) { if ( $ this -> getCountPendingQueue ( ) > 0 ) { throw new QueryException ( 'Queue must be empty, before insertBatch, need executeAsync' ) ; } if ( ! in_array ( $ format , self :: SUPPORTED_FORMATS , true ) ) { t...
insert Batch Stream
51,031
public function tableSize ( string $ tableName ) { $ tables = $ this -> tablesSize ( ) ; if ( isset ( $ tables [ $ tableName ] ) ) { return $ tables [ $ tableName ] ; } return null ; }
Size of tables
51,032
public function partitions ( string $ table , int $ limit = null , bool $ active = null ) { $ database = $ this -> settings ( ) -> getDatabase ( ) ; $ whereActiveClause = $ active === null ? '' : sprintf ( ' AND active = %s' , ( int ) $ active ) ; $ limitClause = $ limit !== null ? ' LIMIT ' . $ limit : '' ; return $ t...
List of partitions
51,033
public function getServerSystemSettings ( string $ like = '' ) { $ l = [ ] ; $ list = $ this -> select ( 'SELECT * FROM system.settings' . ( $ like ? ' WHERE name LIKE :like' : '' ) , [ 'like' => '%' . $ like . '%' ] ) -> rows ( ) ; foreach ( $ list as $ row ) { if ( isset ( $ row [ 'name' ] ) ) { $ n = $ row [ 'name' ...
Read system . settings table
51,034
public function getOAuthClient ( $ client_id , $ client_secret , $ redirect_uri ) { $ options = [ 'clientId' => $ client_id , 'clientSecret' => $ client_secret , 'redirectUri' => $ redirect_uri ] ; $ OAuthClient = new OAuth ( $ options ) ; return $ OAuthClient ; }
Return a new instance of the OAuth Client
51,035
public function getAPIClient ( $ token ) { $ adapter = new \ GuzzleHttp \ Client ( [ 'base_uri' => self :: $ endpoint ] ) ; $ service = new Service \ REST ( $ token , $ adapter ) ; $ APIClient = new Client ( $ service ) ; return $ APIClient ; }
Return a new instance of the API Client
51,036
private function getResult ( $ response ) { $ status = $ response -> getStatusCode ( ) ; if ( $ status == 200 ) { return json_decode ( $ response -> getBody ( ) , JSON_PRETTY_PRINT ) ; } else { return [ $ status => $ response -> getReasonPhrase ( ) ] ; } }
Get a request result . Returns an array with a response body or and error code = > reason .
51,037
private function getResponse ( $ method , $ path , $ parameters ) { try { $ response = $ this -> adapter -> request ( $ method , $ path , $ parameters ) ; return $ this -> getResult ( $ response ) ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } }
Get an API request response and handle possible exceptions .
51,038
public function getAthlete ( $ id = null ) { try { return $ this -> service -> getAthlete ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve current athlete
51,039
public function getAthleteStats ( $ id ) { try { return $ this -> service -> getAthleteStats ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve athlete stats
51,040
public function getAthleteRoutes ( $ id , $ type = null , $ after = null , $ page = null , $ per_page = null ) { try { return $ this -> service -> getAthleteRoutes ( $ id , $ type , $ after , $ page , $ per_page ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; ...
Retrieve athlete routes
51,041
public function getAthleteActivities ( $ before = null , $ after = null , $ page = null , $ per_page = null ) { try { return $ this -> service -> getAthleteActivities ( $ before , $ after , $ page , $ per_page ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } ...
List athlete activities
51,042
public function updateAthlete ( $ city , $ state , $ country , $ sex , $ weight ) { try { return $ this -> service -> updateAthlete ( $ city , $ state , $ country , $ sex , $ weight ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Update current athlete
51,043
public function getActivityFollowing ( $ before = null , $ page = null , $ per_page = null ) { try { return $ this -> service -> getActivityFollowing ( $ before , $ page , $ per_page ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve activity from user followers
51,044
public function getActivity ( $ id , $ include_all_efforts = null ) { try { return $ this -> service -> getActivity ( $ id , $ include_all_efforts ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve an activity
51,045
public function getActivityComments ( $ id , $ markdown = null , $ page = null , $ per_page = null ) { try { return $ this -> service -> getActivityComments ( $ id , $ markdown , $ page , $ per_page ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List activity comments
51,046
public function getActivityKudos ( $ id , $ page = null , $ per_page = null ) { try { return $ this -> service -> getActivityKudos ( $ id , $ page , $ per_page ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List activity kudoers
51,047
public function getActivityPhotos ( $ id , $ size = 2048 , $ photo_sources = 'true' ) { try { return $ this -> service -> getActivityPhotos ( $ id , $ size , $ photo_sources ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List activity photos
51,048
public function getActivityZones ( $ id ) { try { return $ this -> service -> getActivityZones ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List activity zones
51,049
public function getActivityLaps ( $ id ) { try { return $ this -> service -> getActivityLaps ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List activity laps
51,050
public function getActivityUploadStatus ( $ id ) { try { return $ this -> service -> getActivityUploadStatus ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Check upload status
51,051
public function createActivity ( $ name , $ type , $ start_date_local , $ elapsed_time , $ description = null , $ distance = null , $ private = null , $ trainer = null ) { try { return $ this -> service -> createActivity ( $ name , $ type , $ start_date_local , $ elapsed_time , $ description , $ distance , $ private , ...
Create an activity
51,052
public function uploadActivity ( $ file , $ activity_type = null , $ name = null , $ description = null , $ private = null , $ trainer = null , $ commute = null , $ data_type = null , $ external_id = null ) { try { return $ this -> service -> uploadActivity ( $ file , $ activity_type , $ name , $ description , $ privat...
Upload an activity
51,053
public function updateActivity ( $ id , $ name = null , $ type = null , $ private = false , $ commute = false , $ trainer = false , $ gear_id = null , $ description = null ) { try { return $ this -> service -> updateActivity ( $ id , $ name , $ type , $ private , $ commute , $ trainer , $ gear_id , $ description ) ; } ...
Update an activity
51,054
public function getClub ( $ id ) { try { return $ this -> service -> getClub ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve a club
51,055
public function getClubAnnouncements ( $ id ) { try { return $ this -> service -> getClubAnnouncements ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List club announcements
51,056
public function getClubGroupEvents ( $ id ) { try { return $ this -> service -> getClubGroupEvents ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
List club group events
51,057
public function joinClub ( $ id ) { try { return $ this -> service -> joinClub ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Join a club
51,058
public function leaveClub ( $ id ) { try { return $ this -> service -> leaveClub ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Leave a club
51,059
public function getRoute ( $ id ) { try { return $ this -> service -> getRoute ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Get route details
51,060
public function getSegment ( $ id ) { try { return $ this -> service -> getSegment ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve a segment
51,061
public function getStreamsActivity ( $ id , $ types , $ resolution = null , $ series_type = 'distance' ) { try { return $ this -> service -> getStreamsActivity ( $ id , $ types , $ resolution , $ series_type ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve activity streams
51,062
public function getStreamsRoute ( $ id ) { try { return $ this -> service -> getStreamsRoute ( $ id ) ; } catch ( ServiceException $ e ) { throw new ClientException ( '[SERVICE] ' . $ e -> getMessage ( ) ) ; } }
Retrieve route streams
51,063
public function getError ( $ key , $ index = null , $ group = null ) { return $ this -> validator -> getError ( $ key , $ index , $ group ) ; }
Gets the first validation error of a parameter .
51,064
public function getErrors ( $ key = null , $ group = null ) { return $ this -> validator -> getErrors ( $ key , $ group ) ; }
Gets validation errors .
51,065
public function hasError ( $ key , $ group = null ) { return ! empty ( $ this -> validator -> getErrors ( $ key , $ group ) ) ; }
Tells whether there are validation errors for a parameter .
51,066
public function array ( array $ array , array $ rules , string $ group = null , array $ messages = [ ] , $ default = null ) : self { foreach ( $ rules as $ key => $ options ) { $ this -> validateInput ( $ array [ $ key ] ?? $ default , new Configuration ( $ options , $ key , $ group , $ default ) , $ messages ) ; } ret...
Validates an array with the given rules .
51,067
public function object ( $ object , array $ rules , string $ group = null , array $ messages = [ ] , $ default = null ) : self { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 'The first argument should be an object' ) ; } foreach ( $ rules as $ property => $ options ) { $ this -> validateInput ...
Validates an objects properties with the given rules .
51,068
public function request ( Request $ request , array $ rules , string $ group = null , array $ messages = [ ] , $ default = null ) : self { foreach ( $ rules as $ param => $ options ) { $ this -> validateInput ( $ this -> getRequestParam ( $ request , $ param , $ default ) , new Configuration ( $ options , $ param , $ g...
Validates request parameters with the given rules .
51,069
public function value ( $ value , $ rules , string $ key , string $ group = null , array $ messages = [ ] ) : self { return $ this -> validateInput ( $ value , new Configuration ( $ rules , $ key , $ group ) , $ messages ) ; }
Validates a single value with the given rules .
51,070
public function addError ( string $ key , string $ message , string $ group = null ) : self { if ( ! empty ( $ group ) ) { $ this -> errors [ $ group ] [ $ key ] [ ] = $ message ; } else { $ this -> errors [ $ key ] [ ] = $ message ; } return $ this ; }
Adds a validation error .
51,071
public function getFirstError ( string $ key , string $ group = null ) { if ( ! empty ( $ group ) ) { if ( isset ( $ this -> errors [ $ group ] [ $ key ] ) ) { $ first = array_slice ( $ this -> errors [ $ group ] [ $ key ] , 0 , 1 ) ; return array_shift ( $ first ) ; } } if ( isset ( $ this -> errors [ $ key ] ) ) { $ ...
Gets the first error of a parameter .
51,072
public function setDefaultMessage ( string $ rule , string $ message ) : self { $ this -> defaultMessages [ $ rule ] = $ message ; return $ this ; }
Sets the default error message for a validation rule .
51,073
public function setErrors ( array $ errors , string $ key = null , string $ group = null ) : self { if ( ! empty ( $ group ) ) { if ( ! empty ( $ key ) ) { $ this -> errors [ $ group ] [ $ key ] = $ errors ; } else { $ this -> errors [ $ group ] = $ errors ; } } elseif ( ! empty ( $ key ) ) { $ this -> errors [ $ key ]...
Sets validation errors .
51,074
public function setValues ( array $ values , string $ group = null ) : self { foreach ( $ values as $ key => $ value ) { $ this -> setValue ( $ key , $ value , $ group ) ; } return $ this ; }
Sets values of validated data .
51,075
protected function getPropertyValue ( $ object , string $ propertyName , $ default = null ) { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 'The first argument should be an object' ) ; } if ( ! property_exists ( $ object , $ propertyName ) ) { return $ default ; } try { $ reflectionProperty = n...
Gets the value of a property of an object .
51,076
protected function getRulesNames ( AllOf $ rules ) : array { $ rulesNames = [ ] ; foreach ( $ rules -> getRules ( ) as $ rule ) { try { $ rulesNames [ ] = lcfirst ( ( new ReflectionClass ( $ rule ) ) -> getShortName ( ) ) ; } catch ( ReflectionException $ e ) { } } return $ rulesNames ; }
Gets the name of all rules of a group of rules .
51,077
protected function handleValidationException ( NestedValidationException $ e , Configuration $ config , array $ messages = [ ] ) { if ( $ config -> hasMessage ( ) ) { $ this -> setErrors ( [ $ config -> getMessage ( ) ] , $ config -> getKey ( ) , $ config -> getGroup ( ) ) ; } else { $ this -> storeErrors ( $ e , $ con...
Handles a validation exception .
51,078
protected function mergeMessages ( array $ errors ) : array { $ errors = array_filter ( call_user_func_array ( 'array_merge' , $ errors ) ) ; return $ this -> showValidationRules ? $ errors : array_values ( $ errors ) ; }
Merges default messages global messages and individual messages .
51,079
protected function storeErrors ( NestedValidationException $ e , Configuration $ config , array $ messages = [ ] ) { $ errors = [ $ e -> findMessages ( $ this -> getRulesNames ( $ config -> getValidationRules ( ) ) ) ] ; if ( ! empty ( $ this -> defaultMessages ) ) { $ errors [ ] = $ e -> findMessages ( $ this -> defau...
Sets error messages after validation .
51,080
protected function validateInput ( $ input , Configuration $ config , array $ messages = [ ] ) : self { try { $ config -> getValidationRules ( ) -> assert ( $ input ) ; } catch ( NestedValidationException $ e ) { $ this -> handleValidationException ( $ e , $ config , $ messages ) ; } return $ this -> setValue ( $ confi...
Executes the validation of a value and handles errors .
51,081
public function setOptions ( array $ options ) { $ availableOptions = [ 'default' , 'group' , 'key' , 'message' , 'messages' , 'rules' ] ; foreach ( $ availableOptions as $ option ) { if ( isset ( $ options [ $ option ] ) ) { $ this -> $ option = $ options [ $ option ] ; } } }
Sets options from an array .
51,082
public function validateOptions ( ) { if ( ! $ this -> rules instanceof AllOf ) { throw new InvalidArgumentException ( 'Validation rules are missing or invalid' ) ; } if ( ! $ this -> hasKey ( ) ) { throw new InvalidArgumentException ( 'A key must be set' ) ; } if ( $ this -> hasMessage ( ) && ! is_string ( $ this -> m...
Verifies that all mandatory options are set and valid .
51,083
protected function getRawList ( UriInterface $ uri ) : array { $ response = $ this -> getClient ( ) -> get ( $ uri ) ; $ responseArray = $ this -> responseToArray ( $ response ) ; return reset ( $ responseArray ) ; }
Returns a raw API response as an array of a listing API endpoint .
51,084
private function cloneArray ( array & $ array ) : void { foreach ( $ array as $ key => $ value ) { if ( is_object ( $ value ) ) { $ array [ $ key ] = clone $ value ; } if ( is_array ( $ value ) ) { $ this -> cloneArray ( $ array [ $ key ] ) ; } } }
Deep clone for arrays .
51,085
protected function configureOptions ( OptionsResolver $ resolver ) : void { $ resolver -> setDefaults ( [ static :: CONFIG_USER_AGENT_PREFIX => null , static :: CONFIG_HTTP_CLIENT_BUILDER => null , static :: CONFIG_JOURNAL => null , static :: CONFIG_URI_FACTORY => null , static :: CONFIG_REQUEST_FACTORY => null , stati...
Sets default for supported configuration options .
51,086
protected function getDefaultPlugins ( ) : array { $ firstPlugins = [ new BaseUriPlugin ( $ this -> getBaseUri ( ) , [ 'replace' => true ] ) , new HeaderDefaultsPlugin ( $ this -> getDefaultHeaders ( ) ) , ] ; if ( $ this -> authentication ) { $ firstPlugins [ ] = new AuthenticationPlugin ( $ this -> authentication ) ;...
Returns default plugins used by the underlying HTTP client .
51,087
private function resolveConfiguration ( array $ options = [ ] ) : void { $ resolver = new OptionsResolver ( ) ; $ this -> configureOptions ( $ resolver ) ; $ options = $ resolver -> resolve ( $ options ) ; $ this -> userAgentPrefix = $ options [ static :: CONFIG_USER_AGENT_PREFIX ] ; $ this -> httpClientBuilder = $ opt...
Resolve configuration options .
51,088
private function parseErrorResponse ( ResponseInterface $ response ) : array { $ error = [ 'code' => null , 'message' => null , ] ; $ contentTypeHeader = $ response -> getHeaderLine ( 'Content-Type' ) ; if ( $ contentTypeHeader && false !== strpos ( $ contentTypeHeader , 'application/json' ) ) { $ array = json_decode (...
Tries to extract Apigee Edge error code and message from a response .
51,089
private function getEligibleProducts ( string $ type , string $ entityId ) : array { $ products = [ ] ; foreach ( $ this -> getRawList ( $ this -> client -> getUriFactory ( ) -> createUri ( "/mint/organizations/{$this->organization}/{$type}/{$entityId}/eligible-products" ) ) as $ item ) { $ product = $ this -> entitySe...
Returns eligible products of a developer or a company .
51,090
public function normalize ( $ object , $ format = null , array $ context = [ ] ) { $ return = [ 'property' => parent :: normalize ( $ object , $ format , $ context ) , ] ; return ( object ) $ return ; }
Transforms JSON representation of properties property to compatible with what Edge accepts .
51,091
protected function responseArrayToArrayOfEntities ( array $ responseArray , string $ keyGetter = 'id' ) : array { $ entities = [ ] ; foreach ( $ responseArray as $ item ) { $ tmp = $ this -> getEntitySerializer ( ) -> denormalize ( $ item , $ this -> getEntityClass ( ) ) ; $ entities [ $ tmp -> { $ keyGetter } ( ) ] = ...
Parse an API response array to array of entity objects .
51,092
protected function buildEntityCreatePayload ( EntityInterface $ entity , array $ context = [ ] ) : string { return $ this -> getEntitySerializer ( ) -> serialize ( $ entity , 'json' , $ context ) ; }
Serializes the entity to a JSON payload for the request .
51,093
public function setMember ( string $ email , ? string $ role = null ) : array { $ this -> members [ $ email ] = $ role ; return $ this -> members ; }
Add developer or modify developer role in a membership .
51,094
protected function fixTimeZoneOnNormalization ( $ object , $ normalized , \ DateTimeZone $ orgTimezone ) : void { if ( date_default_timezone_get ( ) !== $ orgTimezone -> getName ( ) ) { $ ro = new \ ReflectionObject ( $ object ) ; $ dateDenormalizer = new DateTimeNormalizer ( EntityInterface :: DATE_FORMAT , $ orgTimez...
Fixes the timezone of all DateTimeImmutable objects before the entity is being sent to Apigee Edge .
51,095
protected function fixTimeZoneOnDenormalization ( $ object , $ denormalized , \ DateTimeZone $ orgTimezone ) : void { if ( date_default_timezone_get ( ) !== $ orgTimezone -> getName ( ) ) { $ ro = new \ ReflectionObject ( $ denormalized ) ; $ dateDenormalizer = new DateTimeNormalizer ( EntityInterface :: DATE_FORMAT , ...
Corrects the timezone on all DateTimeImmutable objects if the organization s current timezone is not the default UTC .
51,096
public function denormalize ( $ data , $ class , $ format = null , array $ context = [ ] ) { $ flatten = [ ] ; foreach ( $ data as $ key => $ item ) { if ( is_object ( $ item ) ) { $ flatten [ $ item -> name ] = $ item -> value ; } else { $ flatten [ $ key ] = $ item ; } } $ data = $ flatten ; return parent :: denormal...
Transforms input data to our internal representation .
51,097
protected function responseToArray ( ResponseInterface $ response ) : array { if ( $ response -> getHeaderLine ( 'Content-Type' ) && 0 === strpos ( $ response -> getHeaderLine ( 'Content-Type' ) , 'application/json' ) ) { try { return ( array ) $ this -> jsonDecoder ( ) -> decode ( ( string ) $ response -> getBody ( ) ...
Decodes an Apigee Edge API response to an associative array .
51,098
private static function processTypeErrorOnGetValue ( $ object , string $ property , \ TypeError $ error ) : void { if ( 0 !== strpos ( $ error -> getMessage ( ) , 'Return value of ' ) ) { return ; } $ pos = strpos ( $ error -> getMessage ( ) , $ delim = 'must be of the type ' ) ? : ( strpos ( $ error -> getMessage ( ) ...
Processes type error exception on value get .
51,099
private static function processTypeErrorOnSetValue ( $ message , $ trace , $ i ) : void { if ( 0 !== strpos ( $ message , 'Argument ' ) ) { return ; } if ( isset ( $ trace [ $ i ] [ 'file' ] ) && __FILE__ === $ trace [ $ i ] [ 'file' ] && array_key_exists ( 0 , $ trace [ $ i ] [ 'args' ] ) ) { $ pos = strpos ( $ messag...
Processes type error exception on value set .