idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
7,600
public function decodeFiles ( array $ files ) { $ suiteDocument = new Document ( 'phpbench' ) ; $ rootEl = $ suiteDocument -> createRoot ( 'phpbench' ) ; foreach ( $ files as $ file ) { $ fileDom = new Document ( ) ; $ fileDom -> load ( $ file ) ; foreach ( $ fileDom -> query ( './suite' ) as $ suiteEl ) { $ importedEl...
Return a SuiteCollection from a number of PHPBench xml files .
7,601
public function evaluate ( array $ points ) { $ count = count ( $ this -> dataset ) ; $ bigger = count ( $ points ) > $ count ; if ( $ bigger ) { $ range = $ count - 1 ; } else { $ range = count ( $ points ) - 1 ; } $ result = array_fill ( 0 , count ( $ points ) , 0 ) ; foreach ( range ( 0 , $ range ) as $ i ) { if ( $...
Evaluate the estimated pdf on a set of points .
7,602
public function setBandwidth ( $ bwMethod = null ) { if ( $ bwMethod == 'scott' || null === $ bwMethod ) { $ this -> coVarianceFactor = function ( ) { return pow ( count ( $ this -> dataset ) , - 1. / ( 5 ) ) ; } ; } elseif ( $ bwMethod == 'silverman' ) { $ this -> coVarianceFactor = function ( ) { return pow ( count (...
Compute the estimator bandwidth with given method .
7,603
public function visit ( Constraint $ constraint ) { $ sql = $ this -> doVisit ( $ constraint ) ; $ return = [ $ sql , $ this -> values ] ; $ this -> values = [ ] ; $ this -> paramCounter = 0 ; $ select = [ 'run.id' , 'run.uuid' , 'run.tag' , 'run.date' , 'subject.benchmark' , 'subject.name' , 'subject.id' , 'variant.id...
Convert the given constraint into an SQL query .
7,604
public function findBenchmarks ( $ path , array $ subjectFilter = [ ] , array $ groupFilter = [ ] ) { $ finder = new Finder ( ) ; $ path = PhpBench :: normalizePath ( $ path ) ; if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( sprintf ( 'File or directory "%s" does not exist (cwd: %s)' , $ path ...
Build the BenchmarkMetadata collection .
7,605
public function generateReports ( SuiteCollection $ collection , array $ reportNames ) { $ reportDoms = [ ] ; $ reportConfigs = [ ] ; foreach ( $ reportNames as $ reportName ) { $ reportConfigs [ $ reportName ] = $ this -> generatorRegistry -> getConfig ( $ reportName ) ; } foreach ( $ reportConfigs as $ reportName => ...
Generate the named reports .
7,606
public function getMetric ( $ class , $ metric ) { $ metrics = $ this -> getResult ( $ class ) -> getMetrics ( ) ; if ( ! isset ( $ metrics [ $ metric ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown metric "%s" for result class "%s". Available metrics: "%s"' , $ metric , $ class , implode ( '", "' , a...
Return the named metric for the given result class .
7,607
public function mergeCollection ( self $ collection ) { foreach ( $ collection -> getSuites ( ) as $ suite ) { $ this -> addSuite ( $ suite ) ; } }
Merge another collection into this one .
7,608
public function getParameterSets ( $ file , $ paramProviders ) { $ parameterSets = $ this -> launcher -> payload ( __DIR__ . '/template/parameter_set_extractor.template' , [ 'file' => $ file , 'class' => $ this -> getClassNameFromFile ( $ file ) , 'paramProviders' => var_export ( $ paramProviders , true ) , ] ) -> laun...
Return the parameter sets for the benchmark container in the given file .
7,609
public function toDestUnit ( float $ time , string $ destUnit = null , string $ mode = null ) { return self :: convert ( $ time , $ this -> sourceUnit , $ this -> getDestUnit ( $ destUnit ) , $ this -> getMode ( $ mode ) ) ; }
Convert instance value to given unit .
7,610
public function overrideDestUnit ( $ destUnit ) { self :: validateUnit ( $ destUnit ) ; $ this -> destUnit = $ destUnit ; $ this -> overriddenDestUnit = true ; }
Override the destination unit .
7,611
public function overrideMode ( $ mode ) { self :: validateMode ( $ mode ) ; $ this -> mode = $ mode ; $ this -> overriddenMode = true ; }
Override the mode .
7,612
public function getDestSuffix ( string $ unit = null , string $ mode = null ) { return self :: getSuffix ( $ this -> getDestUnit ( $ unit ) , $ this -> getMode ( $ mode ) ) ; }
Return the destination unit suffix .
7,613
public function format ( float $ time , string $ unit = null , string $ mode = null , int $ precision = null , bool $ suffix = true ) { $ value = number_format ( $ this -> toDestUnit ( $ time , $ unit , $ mode ) , $ precision !== null ? $ precision : $ this -> precision ) ; if ( false === $ suffix ) { return $ value ; ...
Return a human readable representation of the unit including the suffix .
7,614
public static function convert ( float $ time , string $ unit , string $ destUnit , string $ mode ) { self :: validateMode ( $ mode ) ; if ( $ mode === self :: MODE_TIME ) { return self :: convertTo ( $ time , $ unit , $ destUnit ) ; } return self :: convertInto ( $ time , $ unit , $ destUnit ) ; }
Convert given time in given unit to given destination unit in given mode .
7,615
public static function convertInto ( float $ time , string $ unit , string $ destUnit ) { if ( ! $ time ) { return 0 ; } self :: validateUnit ( $ unit ) ; self :: validateUnit ( $ destUnit ) ; $ destMultiplier = self :: $ map [ $ destUnit ] ; $ sourceMultiplier = self :: $ map [ $ unit ] ; $ time = $ destMultiplier / (...
Convert a given time INTO the given unit . That is how many times the given time will fit into the the destination unit . i . e . x per unit .
7,616
public static function convertTo ( float $ time , string $ unit , string $ destUnit ) { self :: validateUnit ( $ unit ) ; self :: validateUnit ( $ destUnit ) ; $ destM = self :: $ map [ $ destUnit ] ; $ sourceM = self :: $ map [ $ unit ] ; $ time = ( $ time * $ sourceM ) / $ destM ; return $ time ; }
Convert the given time from the given unit to the given destination unit .
7,617
public static function getSuffix ( $ unit , $ mode = null ) { self :: validateUnit ( $ unit ) ; $ suffix = self :: $ suffixes [ $ unit ] ; if ( $ mode === self :: MODE_THROUGHPUT ) { return sprintf ( 'ops/%s' , $ suffix ) ; } return $ suffix ; }
Return the suffix for a given unit .
7,618
public function classesFromFile ( $ filename ) { $ classes = $ this -> loader -> load ( $ filename ) ; $ this -> registerClasses ( $ classes ) ; }
Register classes from a given JSON encoded class definition file .
7,619
public function registerClasses ( array $ classDefinitions ) { foreach ( $ classDefinitions as $ className => $ formatDefinitions ) { $ this -> registerClass ( $ className , $ formatDefinitions ) ; } }
Register class definitions .
7,620
public function hasMethod ( $ name ) { foreach ( $ this -> reflectionClasses as $ reflectionClass ) { if ( isset ( $ reflectionClass -> methods [ $ name ] ) ) { return true ; } } return false ; }
Return true if the class hierarchy contains the named method .
7,621
public function hasStaticMethod ( $ name ) { foreach ( $ this -> reflectionClasses as $ reflectionClass ) { if ( isset ( $ reflectionClass -> methods [ $ name ] ) ) { $ method = $ reflectionClass -> methods [ $ name ] ; if ( $ method -> isStatic ) { return true ; } break ; } } return false ; }
Return true if the class hierarchy contains the named static method .
7,622
public function offsetGet ( $ offset ) { if ( ! $ this -> offsetExists ( $ offset ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Column "%s" does not exist, valid columns: "%s"' , $ offset , implode ( '", "' , array_keys ( $ this -> getArrayCopy ( ) ) ) ) ) ; } return parent :: offsetGet ( $ offset ) ; }
Return the given offset . Throw an exception if the given offset does not exist .
7,623
public function register ( $ name , FormatInterface $ format ) { if ( isset ( $ this -> formats [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Formatter with name "%s" is already registered' , $ name ) ) ; } $ this -> formats [ $ name ] = $ format ; }
Register a format class .
7,624
public function get ( $ name ) { if ( ! isset ( $ this -> formats [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown format "%s", known formats: "%s"' , $ name , implode ( ', ' , array_keys ( $ this -> formats ) ) ) ) ; } return $ this -> formats [ $ name ] ; }
Return the named format class .
7,625
public function encode ( SuiteCollection $ suiteCollection ) { $ dom = new Document ( ) ; $ rootEl = $ dom -> createRoot ( 'phpbench' ) ; $ rootEl -> setAttribute ( 'version' , PhpBench :: VERSION ) ; $ rootEl -> setAttributeNS ( 'http://www.w3.org/2000/xmlns/' , 'xmlns:xsi' , 'http://www.w3.org/2001/XMLSchema-instance...
Encode a Suite object into a XML document .
7,626
public function addBaselineCallable ( $ name , $ callable ) { if ( isset ( $ this -> callables [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Baseline callable "%s" has already been registered.' , $ name ) ) ; } if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( sprintf ( '...
Add a baseline callable . The callable can be any callable accepted by call_user_func .
7,627
public function benchmark ( $ name , $ revs ) { if ( ! isset ( $ this -> callables [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown baseline callable "%s", known baseline callables: "%s"' , $ name , implode ( '", "' , array_keys ( $ this -> callables ) ) ) ) ; } $ start = microtime ( true ) ; ...
Return mean time taken to execute the named baseline callable in microseconds .
7,628
private function configureFormatters ( OutputFormatterInterface $ formatter ) { $ formatter -> setStyle ( 'title' , new OutputFormatterStyle ( 'white' , null , [ 'bold' ] ) ) ; $ formatter -> setStyle ( 'subtitle' , new OutputFormatterStyle ( 'white' , null , [ ] ) ) ; $ formatter -> setStyle ( 'description' , new Outp...
Adds some output formatters .
7,629
public function generateUuid ( ) { $ serialized = serialize ( $ this -> envInformations ) ; $ this -> uuid = dechex ( $ this -> getDate ( ) -> format ( 'Ymd' ) ) . substr ( sha1 ( implode ( [ microtime ( ) , $ serialized , $ this -> configPath , ] ) ) , 0 , - 7 ) ; }
Generate a universally unique identifier .
7,630
public function createSubject ( $ name ) { $ subject = new Subject ( $ this , $ name ) ; $ this -> subjects [ $ name ] = $ subject ; return $ subject ; }
Create and add a subject .
7,631
public static function stdev ( array $ values , $ sample = false ) { $ variance = self :: variance ( $ values , $ sample ) ; return \ sqrt ( $ variance ) ; }
Return the standard deviation of a given population .
7,632
public static function variance ( array $ values , $ sample = false ) { $ average = self :: mean ( $ values ) ; $ sum = 0 ; foreach ( $ values as $ value ) { $ diff = pow ( $ value - $ average , 2 ) ; $ sum += $ diff ; } if ( count ( $ values ) === 0 ) { return 0 ; } $ variance = $ sum / ( count ( $ values ) - ( $ samp...
Return the variance for a given population .
7,633
public static function kdeMode ( array $ population , $ space = 512 , $ bandwidth = null ) : float { if ( count ( $ population ) === 1 ) { return current ( $ population ) ; } if ( count ( $ population ) === 0 ) { return 0.0 ; } if ( min ( $ population ) == max ( $ population ) ) { return min ( $ population ) ; } $ kde ...
Return the mode using the kernel density estimator using the normal distribution .
7,634
public static function histogram ( array $ values , $ steps = 10 , $ lowerBound = null , $ upperBound = null ) { $ min = $ lowerBound ? : min ( $ values ) ; $ max = $ upperBound ? : max ( $ values ) ; $ range = $ max - $ min ; $ step = $ range / $ steps ; $ steps ++ ; $ histogram = [ ] ; $ floor = $ min ; for ( $ i = 0...
Generate a histogram .
7,635
public function createIteration ( array $ results = [ ] ) { $ index = count ( $ this -> iterations ) ; $ iteration = new Iteration ( $ index , $ this , $ results ) ; $ this -> iterations [ ] = $ iteration ; return $ iteration ; }
Create and add a new iteration .
7,636
public function getMetricValues ( $ resultClass , $ metricName ) { $ values = [ ] ; foreach ( $ this -> iterations as $ iteration ) { if ( $ iteration -> hasResult ( $ resultClass ) ) { $ values [ ] = $ iteration -> getMetric ( $ resultClass , $ metricName ) ; } } return $ values ; }
Return result values by class and metric name .
7,637
public function getMetricValuesByRev ( $ resultClass , $ metric ) { return array_map ( function ( $ value ) { return $ value / $ this -> getRevolutions ( ) ; } , $ this -> getMetricValues ( $ resultClass , $ metric ) ) ; }
Return the average metric values by revolution .
7,638
public function computeStats ( ) { $ this -> rejects = [ ] ; $ revs = $ this -> getRevolutions ( ) ; if ( 0 === count ( $ this -> iterations ) ) { return ; } $ times = $ this -> getMetricValuesByRev ( TimeResult :: class , 'net' ) ; $ retryThreshold = $ this -> getSubject ( ) -> getRetryThreshold ( ) ; $ this -> stats ...
Calculate and set the deviation from the mean time for each iteration . If the deviation is greater than the rejection threshold then mark the iteration as rejected .
7,639
public function getStats ( ) { if ( null !== $ this -> errorStack ) { throw new \ RuntimeException ( sprintf ( 'Cannot retrieve stats when an exception was encountered ([%s] %s)' , $ this -> errorStack -> getTop ( ) -> getClass ( ) , $ this -> errorStack -> getTop ( ) -> getMessage ( ) ) ) ; } if ( false === $ this -> ...
Return statistics about this iteration collection .
7,640
public function setException ( \ Exception $ exception ) { $ errors = [ ] ; do { $ errors [ ] = Error :: fromException ( $ exception ) ; } while ( $ exception = $ exception -> getPrevious ( ) ) ; $ this -> errorStack = new ErrorStack ( $ this , $ errors ) ; }
Create an error stack from an Exception .
7,641
public function assertionsFromRawCliConfig ( array $ rawAssertions ) { $ assertions = [ ] ; foreach ( $ rawAssertions as $ rawAssertion ) { $ config = $ this -> jsonDecoder -> decode ( $ rawAssertion ) ; $ assertions [ ] = new AssertionMetadata ( $ config ) ; } return $ assertions ; }
Return an array of assertion metadatas from the raw JSON - like stuff from the CLI .
7,642
public function registerService ( $ name , $ serviceId ) { if ( isset ( $ this -> serviceMap [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s service "%s" is already registered' , $ this -> serviceType , $ name ) ) ; } $ this -> serviceMap [ $ name ] = $ serviceId ; $ this -> services [ $ name ] = ...
Register a service ID with against the given name .
7,643
public function setService ( $ name , $ object ) { if ( isset ( $ this -> services [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s service "%s" already exists.' , $ this -> serviceType , $ name ) ) ; } $ this -> services [ $ name ] = $ object ; }
Directly set a named service .
7,644
public function getService ( $ name = null ) { $ name = $ name ? : $ this -> defaultService ; if ( ! $ name ) { throw new \ RuntimeException ( sprintf ( 'You must configure a default %s service, registered %s services: "%s"' , $ this -> serviceType , $ this -> serviceType , implode ( '", "' , array_keys ( $ this -> ser...
Return the named service lazily creating it from the container if it has not yet been accessed .
7,645
private function parse ( $ input , $ context = '' ) { try { $ annotations = $ this -> docParser -> parse ( $ input , $ context ) ; } catch ( AnnotationException $ e ) { if ( ! preg_match ( '/The annotation "(.*)" .* was never imported/' , $ e -> getMessage ( ) , $ matches ) ) { throw $ e ; } throw new \ InvalidArgument...
Delegates to the doctrine DocParser but catches annotation not found errors and throws something useful .
7,646
public function getOrCreateSubject ( $ name ) { if ( isset ( $ this -> subjects [ $ name ] ) ) { return $ this -> subjects [ $ name ] ; } $ this -> subjects [ $ name ] = new SubjectMetadata ( $ this , $ name ) ; return $ this -> subjects [ $ name ] ; }
Get or create a new SubjectMetadata instance with the given name .
7,647
public function filterSubjectNames ( array $ filters ) { foreach ( array_keys ( $ this -> subjects ) as $ subjectName ) { $ unset = true ; foreach ( $ filters as $ filter ) { if ( preg_match ( sprintf ( '{^.*?%s.*?$}' , $ filter ) , sprintf ( '%s::%s' , $ this -> getClass ( ) , $ subjectName ) ) ) { $ unset = false ; b...
Remove all subjects whose name is not in the given list .
7,648
public function filterSubjectGroups ( array $ groups ) { foreach ( $ this -> subjects as $ subjectName => $ subject ) { if ( 0 === count ( array_intersect ( $ subject -> getGroups ( ) , $ groups ) ) ) { unset ( $ this -> subjects [ $ subjectName ] ) ; } } }
Remove all the subjects which are not contained in the given list of groups .
7,649
public function getConfig ( $ name ) { if ( is_array ( $ name ) ) { $ config = $ name ; $ name = uniqid ( ) ; $ this -> setConfig ( $ name , $ config ) ; } $ name = trim ( $ name ) ; $ name = $ this -> processRawCliConfig ( $ name ) ; if ( ! isset ( $ this -> configs [ $ name ] ) ) { throw new \ InvalidArgumentExceptio...
Return the named configuration .
7,650
public function setConfig ( $ name , array $ config ) { if ( isset ( $ this -> configs [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s config "%s" already exists.' , $ this -> serviceType , $ name ) ) ; } $ this -> configs [ $ name ] = $ config ; }
Set a named configuration .
7,651
public function getInformations ( ) { $ informations = [ ] ; foreach ( $ this -> providers as $ provider ) { if ( false === $ provider -> isApplicable ( ) ) { continue ; } $ informations [ ] = $ provider -> getInformation ( ) ; } return $ informations ; }
Return information from the current environment .
7,652
private function getEntryIterator ( ) { $ files = $ this -> days -> current ( ) ; $ files = new \ DirectoryIterator ( $ this -> days -> current ( ) ) ; $ historyEntries = [ ] ; foreach ( $ files as $ file ) { if ( ! $ file -> isFile ( ) ) { continue ; } if ( $ file -> getExtension ( ) !== 'xml' ) { continue ; } $ histo...
Return an iterator for the history entries .
7,653
private function getHistoryEntry ( $ path ) { $ dom = new Document ( ) ; $ dom -> load ( $ path ) ; $ collection = $ this -> xmlDecoder -> decode ( $ dom ) ; $ suites = $ collection -> getSuites ( ) ; $ suite = reset ( $ suites ) ; $ envInformations = $ suite -> getEnvInformations ( ) ; $ vcsBranch = null ; if ( isset ...
Hydrate and return the history entry for the given path .
7,654
private function processDiffs ( array $ tables , Config $ config ) { $ stat = $ config [ 'diff_col' ] ; if ( $ config [ 'compare' ] ) { return $ tables ; } if ( ! in_array ( 'diff' , $ config [ 'cols' ] ) ) { return $ tables ; } if ( ! in_array ( $ stat , $ config [ 'cols' ] ) ) { throw new \ InvalidArgumentException (...
Calculate the diff column if it is displayed .
7,655
private function processSort ( array $ table , Config $ config ) { if ( $ config [ 'sort' ] ) { $ cols = array_reverse ( $ config [ 'sort' ] ) ; foreach ( $ cols as $ colName => $ direction ) { Sort :: mergeSort ( $ table , function ( $ elementA , $ elementB ) use ( $ colName , $ direction ) { if ( $ elementA [ $ colNa...
Process the sorting also break sorting .
7,656
private function processCols ( array $ tables , Config $ config ) { if ( $ config [ 'cols' ] ) { $ cols = $ config [ 'cols' ] ; if ( $ config [ 'compare' ] ) { $ cols [ ] = $ config [ 'compare' ] ; $ cols = array_merge ( $ cols , $ config [ 'compare_fields' ] ) ; } $ tables = F \ map ( $ tables , function ( $ table ) u...
Remove unwanted columns from the tables .
7,657
private function generateDocument ( array $ tables , Config $ config ) { $ document = new Document ( ) ; $ reportsEl = $ document -> createRoot ( 'reports' ) ; $ reportsEl -> setAttribute ( 'name' , 'table' ) ; $ reportEl = $ reportsEl -> appendElement ( 'report' ) ; $ classMap = array_merge ( $ this -> classMap , $ co...
Generate the report DOM document to pass to the report renderer .
7,658
private function resolveCompareColumnName ( Row $ row , $ name , $ index = 1 ) { if ( ! isset ( $ row [ $ name ] ) ) { return $ name ; } $ newName = $ name . '#' . ( string ) $ index ++ ; if ( ! isset ( $ row [ $ newName ] ) ) { return $ newName ; } return $ this -> resolveCompareColumnName ( $ row , $ name , $ index )...
Recursively resolve a comparison column - find a column name that doesn t already exist by adding and incrementing an index .
7,659
private function normalize ( $ jsonString ) { if ( ! is_string ( $ jsonString ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected a string, got "%s"' , gettype ( $ jsonString ) ) ) ; } $ chars = str_split ( $ jsonString ) ; $ inRight = $ inQuote = $ inFakeQuote = false ; $ fakeQuoteStart = null ; if ( empt...
Allow non - strict JSON - i . e . if no quotes are provided then try and add them .
7,660
public function createVariant ( ParameterSet $ parameterSet , $ revolutions , $ warmup , array $ computedStats = [ ] ) { $ variant = new Variant ( $ this , $ parameterSet , $ revolutions , $ warmup , $ computedStats ) ; $ this -> variants [ ] = $ variant ; return $ variant ; }
Create and add a new variant based on this subject .
7,661
public function setFailureCount ( $ service , $ failureCount ) { $ this -> adapter -> save ( $ this -> failureKey ( $ service ) , $ failureCount ) ; }
sets failure count
7,662
public function setLastFailureTime ( $ service , $ lastFailureTime ) { $ this -> adapter -> saveLastFailureTime ( $ this -> lastFailureKey ( $ service ) , $ lastFailureTime ) ; }
sets last failure time
7,663
private function throwExceptionIfErrorOccurred ( ) { $ errorResultCodes = [ \ Memcached :: RES_FAILURE , \ Memcached :: RES_SERVER_TEMPORARILY_DISABLED , \ Memcached :: RES_SERVER_MEMORY_ALLOCATION_FAILURE , ] ; if ( in_array ( $ this -> memcached -> getResultCode ( ) , $ errorResultCodes , true ) ) { throw new Storage...
Throws an exception if some error occurs in memcached .
7,664
public function getAuthorizeUrl ( string $ response_type , int $ client_id , string $ redirect_uri , string $ display , ? array $ scope = null , ? string $ state = null , ? array $ group_ids = null , bool $ revoke = false ) : string { $ scope_mask = 0 ; foreach ( $ scope as $ scope_setting ) { $ scope_mask |= $ scope_s...
Get authorize url
7,665
protected function checkOAuthResponse ( TransportClientResponse $ response ) { $ this -> checkHttpStatus ( $ response ) ; $ body = $ response -> getBody ( ) ; $ decode_body = $ this -> decodeBody ( $ body ) ; if ( isset ( $ decode_body [ static :: RESPONSE_KEY_ERROR ] ) ) { throw new VKOAuthException ( "{$decode_body[s...
Decodes the authorization response and checks its status code and whether it has an error .
7,666
protected function decodeBody ( string $ body ) { $ decoded_body = json_decode ( $ body , true ) ; if ( $ decoded_body === null || ! is_array ( $ decoded_body ) ) { $ decoded_body = [ ] ; } return $ decoded_body ; }
Decodes body .
7,667
public function listen ( ? int $ ts = null ) { if ( $ this -> server === null ) { $ this -> server = $ this -> getLongPollServer ( ) ; } if ( $ this -> last_ts === null ) { $ this -> last_ts = $ this -> server [ static :: SERVER_TIMESTAMP ] ; } if ( $ ts === null ) { $ ts = $ this -> last_ts ; } try { $ response = $ th...
Starts listening to LongPoll events .
7,668
protected function getLongPollServer ( ) { $ params = array ( static :: PARAM_GROUP_ID => $ this -> group_id ) ; $ server = $ this -> api_client -> groups ( ) -> getLongPollServer ( $ this -> access_token , $ params ) ; return array ( static :: SERVER_URL => $ server [ 'server' ] , static :: SERVER_TIMESTAMP => $ serve...
Get long poll server
7,669
public function getEvents ( string $ host , string $ key , int $ ts ) { $ params = array ( static :: PARAM_KEY => $ key , static :: PARAM_TS => $ ts , static :: PARAM_WAIT => $ this -> wait , static :: PARAM_ACT => static :: VALUE_ACT ) ; try { $ response = $ this -> http_client -> get ( $ host , $ params ) ; } catch (...
Retrieves events from long poll server starting from the specified timestamp .
7,670
private function parseResponse ( array $ params , TransportClientResponse $ response ) { $ this -> checkHttpStatus ( $ response ) ; $ body = $ response -> getBody ( ) ; $ decode_body = $ this -> decodeBody ( $ body ) ; if ( isset ( $ decode_body [ static :: EVENTS_FAILED ] ) ) { switch ( $ decode_body [ static :: EVENT...
Decodes the LongPoll response and checks its status code and whether it has a failed key .
7,671
public function get ( string $ url , ? array $ payload = null ) : TransportClientResponse { return $ this -> sendRequest ( $ url . static :: QUESTION_MARK . http_build_query ( $ payload ) , array ( ) ) ; }
Makes get request .
7,672
public function upload ( string $ url , string $ parameter_name , string $ path ) : TransportClientResponse { $ payload = array ( ) ; $ payload [ $ parameter_name ] = ( class_exists ( 'CURLFile' , false ) ) ? new \ CURLFile ( $ path ) : '@' . $ path ; return $ this -> sendRequest ( $ url , array ( CURLOPT_POST => 1 , C...
Makes upload request .
7,673
public function sendRequest ( string $ url , array $ opts ) { $ curl = curl_init ( $ url ) ; curl_setopt_array ( $ curl , $ this -> initial_opts + $ opts ) ; $ response = curl_exec ( $ curl ) ; $ curl_error_code = curl_errno ( $ curl ) ; $ curl_error = curl_error ( $ curl ) ; $ http_status = curl_getinfo ( $ curl , CUR...
Makes and sends request .
7,674
protected function parseRawResponse ( int $ http_status , string $ response ) { list ( $ raw_headers , $ body ) = $ this -> extractResponseHeadersAndBody ( $ response ) ; $ headers = $ this -> getHeaders ( $ raw_headers ) ; return new TransportClientResponse ( $ http_status , $ headers , $ body ) ; }
Breaks the raw response down into its headers body and http status code .
7,675
protected function extractResponseHeadersAndBody ( string $ response ) { $ parts = explode ( "\r\n\r\n" , $ response ) ; $ raw_body = array_pop ( $ parts ) ; $ raw_headers = implode ( "\r\n\r\n" , $ parts ) ; return [ trim ( $ raw_headers ) , trim ( $ raw_body ) ] ; }
Extracts the headers and the body into a two - part array .
7,676
protected function getHeaders ( string $ raw_headers ) { $ raw_headers = str_replace ( "\r\n" , "\n" , $ raw_headers ) ; $ header_collection = explode ( "\n\n" , trim ( $ raw_headers ) ) ; $ raw_header = array_pop ( $ header_collection ) ; $ header_components = explode ( "\n" , $ raw_header ) ; $ result = array ( ) ; $...
Parses the raw headers and sets as an array .
7,677
public function upload ( string $ upload_url , string $ parameter_name , string $ path ) { try { $ response = $ this -> http_client -> upload ( $ upload_url , $ parameter_name , $ path ) ; } catch ( TransportRequestException $ e ) { throw new VKClientException ( $ e ) ; } return $ this -> parseResponse ( $ response ) ;...
Uploads data by its path to the given url .
7,678
private function parseResponse ( TransportClientResponse $ response ) { $ this -> checkHttpStatus ( $ response ) ; $ body = $ response -> getBody ( ) ; $ decode_body = $ this -> decodeBody ( $ body ) ; if ( isset ( $ decode_body [ static :: KEY_ERROR ] ) ) { $ error = $ decode_body [ static :: KEY_ERROR ] ; $ api_error...
Decodes the response and checks its status code and whether it has an Api error . Returns decoded response .
7,679
private function formatParams ( array $ params ) { foreach ( $ params as $ key => $ value ) { if ( is_array ( $ value ) ) { $ params [ $ key ] = implode ( ',' , $ value ) ; } else if ( is_bool ( $ value ) ) { $ params [ $ key ] = $ value ? 1 : 0 ; } } return $ params ; }
Formats given array of parameters for making the request .
7,680
public function send ( DocumentInterface $ document ) { $ xml = $ this -> getXmlSigned ( $ document ) ; return $ this -> sender -> send ( $ document -> getName ( ) , $ xml ) ; }
Build and send document .
7,681
public function getXmlSigned ( DocumentInterface $ document ) { $ classDoc = get_class ( $ document ) ; return $ this -> factory -> setBuilder ( $ this -> getBuilder ( $ classDoc ) ) -> getXmlSigned ( $ document ) ; }
Get signed xml from document .
7,682
public function send ( DocumentInterface $ document ) { $ classDoc = get_class ( $ document ) ; $ this -> factory -> setBuilder ( $ this -> getBuilder ( $ classDoc ) ) -> setSender ( $ this -> getSender ( $ classDoc ) ) ; return $ this -> factory -> send ( $ document ) ; }
Envia documento .
7,683
public function sendXml ( $ type , $ name , $ xml ) { $ this -> factory -> setBuilder ( $ this -> getBuilder ( $ type ) ) -> setSender ( $ this -> getSender ( $ type ) ) ; return $ this -> factory -> sendXml ( $ name , $ xml ) ; }
Envia xml generado .
7,684
protected function attempLoginUsingUsernameAsAnEmail ( Request $ request ) { return $ this -> guard ( ) -> attempt ( [ 'email' => $ request -> input ( 'username' ) , 'password' => $ request -> input ( 'password' ) ] , $ request -> has ( 'remember' ) ) ; }
Attempt to log the user into application using username as an email .
7,685
protected function createAdminUser ( ) { try { factory ( get_class ( app ( 'App\User' ) ) ) -> create ( [ "name" => env ( 'ADMIN_USER' , $ this -> username ( ) ) , "email" => env ( 'ADMIN_EMAIL' , $ this -> email ( ) ) , "password" => bcrypt ( env ( 'ADMIN_PWD' , '123456' ) ) ] ) ; } catch ( \ Illuminate \ Database \ Q...
Create admin user .
7,686
protected function sendResetLinkResponse ( Request $ request , $ response ) { if ( $ request -> expectsJson ( ) ) { return response ( ) -> json ( [ 'status' => trans ( $ response ) ] ) ; } return back ( ) -> with ( 'status' , trans ( $ response ) ) ; }
Get the response for a successful password reset link .
7,687
protected function obtainReplacements ( ) { return [ 'ROUTE_LINK' => $ link = $ this -> getReplacements ( ) [ 0 ] , 'ROUTE_CONTROLLER' => $ this -> controller ( $ this -> getReplacements ( ) [ 1 ] ) , 'ROUTE_METHOD' => $ this -> getReplacements ( ) [ 2 ] , 'ROUTE_NAME' => dot_path ( $ link ) , ] ; }
Obtain replacements .
7,688
public function publicAssets ( ) { return [ ADMINLTETEMPLATE_PATH . '/public/css' => public_path ( 'css' ) , ADMINLTETEMPLATE_PATH . '/public/js' => public_path ( 'js' ) , ADMINLTETEMPLATE_PATH . '/public/fonts' => public_path ( 'fonts' ) , ADMINLTETEMPLATE_PATH . '/public/img' => public_path ( 'img' ) , ADMINLTETEMPLA...
Public assets copy path .
7,689
public function views ( ) { return [ ADMINLTETEMPLATE_PATH . '/resources/views/auth' => resource_path ( 'views/vendor/adminlte/auth' ) , ADMINLTETEMPLATE_PATH . '/resources/views/errors' => resource_path ( 'views/vendor/adminlte/errors' ) , ADMINLTETEMPLATE_PATH . '/resources/views/layouts' => resource_path ( 'views/ve...
Views copy path .
7,690
public function resourceAssets ( ) { return [ ADMINLTETEMPLATE_PATH . '/resources/assets/css' => resource_path ( 'assets/css' ) , ADMINLTETEMPLATE_PATH . '/resources/assets/img' => resource_path ( 'assets/img' ) , ADMINLTETEMPLATE_PATH . '/resources/assets/js' => resource_path ( 'assets/js' ) , ADMINLTETEMPLATE_PATH . ...
Resource assets copy path .
7,691
private function install ( $ files ) { foreach ( $ files as $ fileSrc => $ fileDst ) { if ( file_exists ( $ fileDst ) && ! $ this -> force && ! $ this -> confirmOverwrite ( basename ( $ fileDst ) ) ) { return ; } if ( $ this -> files -> isFile ( $ fileSrc ) ) { $ this -> publishFile ( $ fileSrc , $ fileDst ) ; } elseif...
Install files from array .
7,692
protected function command ( ) { $ api = $ this -> option ( 'api' ) ? ' --api ' : '' ; $ action = $ this -> argument ( 'action' ) ? ' ' . $ this -> argument ( 'action' ) . ' ' : '' ; return 'php artisan make:route ' . $ this -> argument ( 'link' ) . $ action . ' --type=' . $ this -> option ( 'type' ) . ' --method=' . $...
Obtain command .
7,693
protected function controllerMethod ( $ controllername ) { if ( str_contains ( $ controller = $ controllername , '@' ) ) { return substr ( $ controllername , strpos ( $ controllername , '@' ) + 1 , strlen ( $ controllername ) ) ; } return 'index' ; }
Get method from controller name .
7,694
protected function email ( ) { if ( ( $ email = env ( 'ADMIN_EMAIL' , null ) ) != null ) { return $ email ; } if ( ( $ email = git_user_email ( ) ) != null ) { return $ email ; } return "admin@example.com" ; }
Obtain admin email .
7,695
public function username ( ) { if ( ( $ username = env ( 'ADMIN_USERNAME' , null ) ) != null ) { return $ username ; } if ( ( $ username = git_user_name ( ) ) != null ) { return $ username ; } return "Admin" ; }
Obtains username .
7,696
protected function routeExists ( $ link ) { if ( $ this -> option ( 'api' ) ) { return $ this -> apiRouteExists ( $ link ) ; } return $ this -> webRouteExists ( $ link ) ; }
Check if route exists .
7,697
protected function webRouteExists ( $ link ) { $ link = $ this -> removeTrailingSlashIfExists ( $ link ) ; $ link = $ this -> removeDuplicatedTrailingSlashes ( $ link ) ; foreach ( Route :: getRoutes ( ) as $ value ) { if ( in_array ( strtoupper ( $ this -> option ( 'method' ) ) , array_merge ( $ value -> methods ( ) ,...
Check if web route exists .
7,698
protected function action ( ) { if ( $ this -> argument ( 'action' ) != null ) { return $ this -> argument ( 'action' ) ; } if ( strtolower ( $ this -> option ( 'type' ) ) != 'regular' ) { return $ this -> argument ( 'link' ) . 'Controller' ; } return $ this -> argument ( 'link' ) ; }
Get the action replacement .
7,699
protected function validateMethod ( ) { if ( ! in_array ( strtoupper ( $ this -> option ( 'method' ) ) , $ methods = array_merge ( Router :: $ verbs , [ 'ANY' ] ) ) ) { throw new MethodNotAllowedException ( $ methods ) ; } }
Validate option method .