idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
55,200 | protected function logCollectedSourceFiles ( JsonFile $ jsonFile ) { $ sourceFiles = $ jsonFile -> getSourceFiles ( ) ; $ numFiles = count ( $ sourceFiles ) ; $ this -> logger -> info ( sprintf ( 'Found <info>%s</info> source file%s:' , number_format ( $ numFiles ) , $ numFiles > 1 ? 's' : '' ) ) ; foreach ( $ sourceFi... | Log collected source files . |
55,201 | protected function logResponse ( Response $ response ) { $ raw_body = ( string ) $ response -> getBody ( ) ; $ body = json_decode ( $ raw_body , true ) ; if ( $ body === null ) { $ this -> logger -> error ( $ raw_body ) ; } elseif ( isset ( $ body [ 'error' ] ) ) { if ( isset ( $ body [ 'message' ] ) ) { $ this -> logg... | Log response . |
55,202 | public function getHelpMessage ( ) { $ message = $ this -> message . "\n" ; if ( is_array ( $ this -> readEnv ) ) { foreach ( $ this -> readEnv as $ envVarName => $ value ) { $ message .= $ this -> format ( $ envVarName , $ value ) ; } } $ message .= <<< 'EOL'Set environment variables properly like the following.For T... | Return help message . |
55,203 | protected function format ( $ key , $ value ) { if ( in_array ( $ key , self :: $ secretEnvVars , true ) && is_string ( $ value ) && strlen ( $ value ) > 0 ) { $ value = '********(HIDDEN)' ; } return sprintf ( " - %s=%s\n" , $ key , var_export ( $ value , true ) ) ; } | Format a pair of the envVarName and the value . |
55,204 | public function collectGitInfo ( ) { $ command = new GitCommand ( ) ; $ gitCollector = new GitInfoCollector ( $ command ) ; $ this -> jsonFile -> setGit ( $ gitCollector -> collect ( ) ) ; return $ this ; } | Collect git repository info into json_file . |
55,205 | public function dumpJsonFile ( ) { $ jsonPath = $ this -> config -> getJsonPath ( ) ; file_put_contents ( $ jsonPath , $ this -> jsonFile ) ; return $ this ; } | Dump uploading json file . |
55,206 | public function send ( ) { if ( $ this -> config -> isDryRun ( ) ) { return ; } $ jsonPath = $ this -> config -> getJsonPath ( ) ; return $ this -> upload ( static :: URL , $ jsonPath , static :: FILENAME ) ; } | Send json_file to jobs API . |
55,207 | public function collect ( \ SimpleXMLElement $ xml , $ rootDir ) { $ root = rtrim ( $ rootDir , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( $ this -> jsonFile === null ) { $ this -> jsonFile = new JsonFile ( ) ; } $ runAt = $ this -> collectRunAt ( $ xml ) ; $ this -> jsonFile -> setRunAt ( $ runAt ) ; $ xpaths ... | Collect coverage from XML object . |
55,208 | protected function collectRunAt ( \ SimpleXMLElement $ xml , $ format = 'Y-m-d H:i:s O' ) { $ timestamp = $ xml -> project [ 'timestamp' ] ; $ runAt = new \ DateTime ( '@' . $ timestamp ) ; return $ runAt -> format ( $ format ) ; } | Collect timestamp when the job ran . |
55,209 | protected function collectFileCoverage ( \ SimpleXMLElement $ file , $ root ) { $ absolutePath = realpath ( ( string ) ( $ file [ 'path' ] ? : $ file [ 'name' ] ) ) ; if ( strpos ( $ absolutePath , $ root ) === false ) { return ; } $ filename = $ absolutePath ; if ( $ root !== DIRECTORY_SEPARATOR ) { $ filename = str_r... | Collect coverage data of a file . |
55,210 | protected function collectCoverage ( \ SimpleXMLElement $ file , $ path , $ filename ) { if ( $ this -> jsonFile -> hasSourceFile ( $ path ) ) { $ srcFile = $ this -> jsonFile -> getSourceFile ( $ path ) ; } else { $ srcFile = new SourceFile ( $ path , $ filename ) ; } foreach ( $ file -> line as $ line ) { if ( ( stri... | Collect coverage data . |
55,211 | protected function fillTravisCi ( ) { if ( isset ( $ this -> env [ 'TRAVIS' ] ) && $ this -> env [ 'TRAVIS' ] && isset ( $ this -> env [ 'TRAVIS_JOB_ID' ] ) ) { $ this -> env [ 'CI_JOB_ID' ] = $ this -> env [ 'TRAVIS_JOB_ID' ] ; if ( $ this -> config -> hasServiceName ( ) ) { $ this -> env [ 'CI_NAME' ] = $ this -> con... | Fill Travis CI environment variables . |
55,212 | protected function fillLocal ( ) { if ( isset ( $ this -> env [ 'COVERALLS_RUN_LOCALLY' ] ) && $ this -> env [ 'COVERALLS_RUN_LOCALLY' ] ) { $ this -> env [ 'CI_JOB_ID' ] = null ; $ this -> env [ 'CI_NAME' ] = 'php-coveralls' ; $ this -> env [ 'COVERALLS_EVENT_TYPE' ] = 'manual' ; $ this -> readEnv [ 'COVERALLS_RUN_LOC... | Fill local environment variables . |
55,213 | protected function fillRepoToken ( ) { if ( $ this -> config -> hasRepoToken ( ) ) { $ this -> env [ 'COVERALLS_REPO_TOKEN' ] = $ this -> config -> getRepoToken ( ) ; } if ( isset ( $ this -> env [ 'COVERALLS_REPO_TOKEN' ] ) ) { $ this -> readEnv [ 'COVERALLS_REPO_TOKEN' ] = $ this -> env [ 'COVERALLS_REPO_TOKEN' ] ; }... | Fill repo_token for unsupported CI service . |
55,214 | protected function executeApi ( Configuration $ config ) { $ client = new Client ( ) ; $ api = new Jobs ( $ config , $ client ) ; $ repository = new JobsRepository ( $ api , $ config ) ; $ repository -> setLogger ( $ this -> logger ) ; return $ repository -> persist ( ) ; } | Execute Jobs API . |
55,215 | protected function parse ( $ coverallsYmlPath ) { $ file = new Path ( ) ; $ path = realpath ( $ coverallsYmlPath ) ; if ( $ file -> isRealFileReadable ( $ path ) ) { $ parser = new Parser ( ) ; $ yml = $ parser -> parse ( file_get_contents ( $ path ) ) ; return empty ( $ yml ) ? [ ] : $ yml ; } return [ ] ; } | Parse . coveralls . yml . |
55,216 | protected function process ( array $ yml ) { $ processor = new Processor ( ) ; $ configuration = new CoverallsConfiguration ( ) ; return $ processor -> processConfiguration ( $ configuration , [ 'coveralls' => $ yml ] ) ; } | Process parsed configuration according to the configuration definition . |
55,217 | protected function createConfiguration ( array $ options , $ rootDir , InputInterface $ input = null ) { $ configuration = new Configuration ( ) ; $ file = new Path ( ) ; $ repoToken = $ options [ 'repo_token' ] ; $ repoSecretToken = $ options [ 'repo_secret_token' ] ; $ coverage_clover = $ options [ 'coverage_clover' ... | Create coveralls configuration . |
55,218 | protected function ensureCloverXmlPaths ( $ option , $ rootDir , Path $ file ) { if ( is_array ( $ option ) ) { return $ this -> getGlobPathsFromArrayOption ( $ option , $ rootDir , $ file ) ; } return $ this -> getGlobPathsFromStringOption ( $ option , $ rootDir , $ file ) ; } | Ensure coverage_clover is valid . |
55,219 | protected function getGlobPaths ( $ path ) { $ paths = [ ] ; $ iterator = new \ GlobIterator ( $ path ) ; foreach ( $ iterator as $ fileInfo ) { $ paths [ ] = $ fileInfo -> getPathname ( ) ; } if ( count ( $ paths ) === 0 ) { throw new InvalidConfigurationException ( "coverage_clover XML file is not readable: ${path}" ... | Return absolute paths from glob path . |
55,220 | protected function getGlobPathsFromStringOption ( $ option , $ rootDir , Path $ file ) { if ( ! is_string ( $ option ) ) { throw new InvalidConfigurationException ( 'coverage_clover XML file option must be a string' ) ; } $ path = $ file -> toAbsolutePath ( $ option , $ rootDir ) ; return $ this -> getGlobPaths ( $ pat... | Return absolute paths from string option value . |
55,221 | protected function getGlobPathsFromArrayOption ( array $ options , $ rootDir , Path $ file ) { $ paths = [ ] ; foreach ( $ options as $ option ) { $ paths = array_merge ( $ paths , $ this -> getGlobPathsFromStringOption ( $ option , $ rootDir , $ file ) ) ; } return $ paths ; } | Return absolute paths from array option values . |
55,222 | protected function ensureJsonPath ( $ option , $ rootDir , Path $ file ) { $ realpath = $ file -> getRealWritingFilePath ( $ option , $ rootDir ) ; $ realFilePath = $ file -> getRealPath ( $ realpath , $ rootDir ) ; if ( $ realFilePath !== false && ! $ file -> isRealFileWritable ( $ realFilePath ) ) { throw new Invalid... | Ensure json_path is valid . |
55,223 | public function addCoverage ( $ lineNum , $ count ) { if ( array_key_exists ( $ lineNum , $ this -> coverage ) ) { $ this -> coverage [ $ lineNum ] += $ count ; } } | Add coverage . |
55,224 | public function getMetrics ( ) { if ( $ this -> metrics === null ) { $ this -> metrics = new Metrics ( $ this -> coverage ) ; } return $ this -> metrics ; } | Return metrics . |
55,225 | public function excludeNoStatementsFiles ( ) { $ this -> sourceFiles = array_filter ( $ this -> sourceFiles , function ( SourceFile $ sourceFile ) { return $ sourceFile -> getMetrics ( ) -> hasStatements ( ) ; } ) ; } | Exclude source files that have no executable statements . |
55,226 | protected function toJsonProperty ( $ prop ) { if ( $ prop instanceof Coveralls ) { return $ prop -> toArray ( ) ; } if ( is_array ( $ prop ) ) { return $ this -> toJsonPropertyArray ( $ prop ) ; } return $ prop ; } | Convert to json property . |
55,227 | protected function fillStandardizedEnvVars ( array $ env ) { $ map = [ 'serviceName' => 'CI_NAME' , 'serviceNumber' => 'CI_BUILD_NUMBER' , 'serviceBuildUrl' => 'CI_BUILD_URL' , 'serviceBranch' => 'CI_BRANCH' , 'servicePullRequest' => 'CI_PULL_REQUEST' , 'serviceJobId' => 'CI_JOB_ID' , 'serviceEventType' => 'COVERALLS_E... | Fill standardized environment variables . |
55,228 | protected function ensureJobs ( ) { if ( ! $ this -> hasSourceFiles ( ) ) { throw new \ RuntimeException ( 'source_files must be set' ) ; } if ( $ this -> requireServiceJobId ( ) ) { return $ this ; } if ( $ this -> requireServiceNumber ( ) ) { return $ this ; } if ( $ this -> requireServiceEventType ( ) ) { return $ t... | Ensure data consistency for jobs API . |
55,229 | protected function isUnsupportedServiceJob ( ) { return $ this -> serviceJobId === null && $ this -> serviceNumber === null && $ this -> serviceEventType === null && $ this -> repoToken !== null ; } | Return whether the job is running on unsupported service . |
55,230 | public function merge ( self $ that ) { $ this -> statements += $ that -> statements ; $ this -> coveredStatements += $ that -> coveredStatements ; $ this -> lineCoverage = null ; } | Merge other metrics . |
55,231 | public function command ( $ expression , $ callable , array $ aliases = [ ] ) { $ this -> assertCallableIsValid ( $ callable ) ; $ commandFunction = function ( InputInterface $ input , OutputInterface $ output ) use ( $ callable ) { $ parameters = array_merge ( [ 'input' => $ input , 'output' => $ output , InputInterfa... | Define a CLI command using a string expression and a callable . |
55,232 | public function useContainer ( ContainerInterface $ container , $ injectByTypeHint = false , $ injectByParameterName = false ) { $ this -> container = $ container ; $ resolver = $ this -> createParameterResolver ( ) ; if ( $ injectByTypeHint ) { $ resolver -> appendResolver ( new TypeHintContainerResolver ( $ container... | Set up the application to use a container to resolve callables . |
55,233 | public function runCommand ( $ command , OutputInterface $ output = null ) { $ input = new StringInput ( $ command ) ; $ command = $ this -> find ( $ this -> getCommandName ( $ input ) ) ; return $ command -> run ( $ input , $ output ? : new NullOutput ( ) ) ; } | Helper to run a sub - command from a command . |
55,234 | public function defaults ( array $ defaults = [ ] ) { $ definition = $ this -> getDefinition ( ) ; foreach ( $ defaults as $ name => $ default ) { if ( $ definition -> hasArgument ( $ name ) ) { $ input = $ definition -> getArgument ( $ name ) ; } elseif ( $ definition -> hasOption ( $ name ) ) { $ input = $ definition... | Define default values for the arguments of the command . |
55,235 | public function createCustomToken ( $ uid , array $ claims = [ ] , \ DateTimeInterface $ expiresAt = null ) : Token { if ( count ( $ claims ) ) { $ this -> builder -> set ( 'claims' , $ claims ) ; } $ this -> builder -> set ( 'uid' , ( string ) $ uid ) ; $ now = time ( ) ; $ expiration = $ expiresAt ? $ expiresAt -> ge... | Returns a token for the given user and claims . |
55,236 | public static function rmdir ( $ files ) { if ( $ files instanceof \ Traversable ) { $ files = \ iterator_to_array ( $ files , false ) ; } elseif ( ! \ is_array ( $ files ) ) { $ files = [ $ files ] ; } $ files = \ array_reverse ( $ files ) ; foreach ( $ files as $ file ) { if ( \ is_link ( $ file ) ) { \ unlink ( $ fi... | Modified copy of Symphony filesystem remove |
55,237 | private function getDownloader ( ) : InstallerInterface { $ installers = \ array_reverse ( $ this -> installers ) ; foreach ( $ installers as $ installer ) { if ( $ installer -> isEligible ( ) ) { return $ installer ; } } throw new NoDownloaderFoundException ( 'No eligible downloader found for Mock Server binaries.' ) ... | Get the first downloader that meets the systems eligibility . |
55,238 | public function willRespondWith ( ProviderResponse $ response ) : bool { $ this -> interaction -> setResponse ( $ response ) ; return $ this -> mockServerHttpService -> registerInteraction ( $ this -> interaction ) ; } | Make the http request to the Mock Service to register the interaction . |
55,239 | public function getHelloString ( string $ name ) : string { $ response = $ this -> httpClient -> get ( new Uri ( "{$this->baseUri}/hello/{$name}" ) , [ 'headers' => [ 'Content-Type' => 'application/json' ] ] ) ; $ body = $ response -> getBody ( ) ; $ object = \ json_decode ( $ body ) ; return $ object -> message ; } | Get Hello String |
55,240 | public function getGoodbyeString ( string $ name ) : string { $ response = $ this -> httpClient -> get ( "{$this->baseUri}/goodbye/{$name}" , [ 'headers' => [ 'Content-Type' => 'application/json' ] ] ) ; $ body = $ response -> getBody ( ) ; $ object = \ json_decode ( $ body ) ; return $ object -> message ; } | Get Goodbye String |
55,241 | private function download ( string $ fileName , string $ tempFilePath ) : self { $ uri = 'https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v' . self :: VERSION . "/{$fileName}" ; $ data = \ file_get_contents ( $ uri ) ; if ( $ data === false ) { throw new FileDownloadFailureException ( 'Failed ... | Download the binaries . |
55,242 | public function verify ( ) : bool { if ( ! $ this -> callback ) { throw new \ Exception ( 'Callbacks need to exist to run verify.' ) ; } $ pactJson = $ this -> reify ( ) ; try { \ call_user_func ( $ this -> callback , $ pactJson ) ; return $ this -> writePact ( ) ; } catch ( \ Exception $ e ) { return false ; } } | Verify the use of the pact by calling the callback It also calls finalize to write the pact |
55,243 | public function writePact ( ) : bool { $ pactJson = \ json_encode ( $ this -> message ) ; return $ this -> pactMessage -> update ( $ pactJson , $ this -> config -> getConsumer ( ) , $ this -> config -> getProvider ( ) , $ this -> config -> getPactDir ( ) ) ; } | Write the Pact without deleting the interactions . |
55,244 | public function run ( array $ arguments , $ processTimeout , $ processIdleTimeout ) { $ scripts = $ this -> installManager -> install ( ) ; $ processRunner = new ProcessRunner ( $ scripts -> getProviderVerifier ( ) , $ arguments ) ; $ logHandler = new StreamHandler ( new ResourceOutputStream ( \ STDOUT ) ) ; $ logHandl... | Execute the Pact Verifier Service . |
55,245 | public function verify ( string $ consumerName , string $ tag = null , string $ consumerVersion = null ) : self { $ path = "pacts/provider/{$this->config->getProviderName()}/consumer/{$consumerName}/" ; if ( $ tag ) { $ path .= "latest/{$tag}/" ; } elseif ( $ consumerVersion ) { $ path .= "version/{$consumerVersion}/" ... | Make the request to the PACT Verifier Service to run a Pact file tests from the Pact Broker . |
55,246 | public function verifyFiles ( array $ files ) : self { $ arguments = \ array_merge ( $ files , $ this -> getArguments ( ) ) ; $ this -> verifyAction ( $ arguments ) ; return $ this ; } | Provides a way to validate local Pact JSON files . |
55,247 | public function verifyAll ( ) { $ arguments = $ this -> getBrokerHttpClient ( ) -> getAllConsumerUrls ( $ this -> config -> getProviderName ( ) ) ; $ arguments = \ array_merge ( $ arguments , $ this -> getArguments ( ) ) ; $ this -> verifyAction ( $ arguments ) ; } | Verify all Pacts from the Pact Broker are valid for the Provider . |
55,248 | public function verifyAllForTag ( string $ tag ) { $ arguments = $ this -> getBrokerHttpClient ( ) -> getAllConsumerUrlsForTag ( $ this -> config -> getProviderName ( ) , $ tag ) ; $ arguments = \ array_merge ( $ arguments , $ this -> getArguments ( ) ) ; $ this -> verifyAction ( $ arguments ) ; } | Verify all PACTs for a given tag . |
55,249 | protected function verifyAction ( array $ arguments ) { $ this -> verifierProcess -> run ( $ arguments , $ this -> processTimeout , $ this -> processIdleTimeout ) ; } | Trigger execution of the Pact Verifier Service . |
55,250 | private function parseEnv ( string $ variableName , bool $ required = true ) { $ result = null ; if ( \ getenv ( $ variableName ) === 'false' ) { $ result = false ; } elseif ( \ getenv ( $ variableName ) === 'true' ) { $ result = true ; } if ( \ getenv ( $ variableName ) !== false ) { $ result = \ getenv ( $ variableNa... | Parse environmental variables to be either null if not required or throw an error if required . |
55,251 | public function term ( $ value , string $ pattern ) : array { $ result = \ preg_match ( "/$pattern/" , $ value ) ; if ( $ result === false || $ result === 0 ) { $ errorCode = \ preg_last_error ( ) ; throw new \ Exception ( "The pattern {$pattern} is not valid for value {$value}. Failed with error code {$errorCode}." ) ... | Validate that a value will match a regex pattern . |
55,252 | public function start ( ) : int { $ scripts = $ this -> installManager -> install ( ) ; $ this -> processRunner = new ProcessRunner ( $ scripts -> getStubService ( ) , $ this -> getArguments ( ) ) ; $ processId = $ this -> processRunner -> run ( ) ; \ sleep ( 1 ) ; return $ processId ; } | Start the Stub Server . Verify that it is running . |
55,253 | public function run ( $ blocking = false ) : int { $ logHandler = new StreamHandler ( new ResourceOutputStream ( \ STDOUT ) ) ; $ logHandler -> setFormatter ( new ConsoleFormatter ) ; $ logger = new Logger ( 'server' ) ; $ logger -> pushHandler ( $ logHandler ) ; $ pid = null ; $ lambdaLoop = function ( ) use ( $ block... | Run the process and set output |
55,254 | public function stop ( ) : bool { $ this -> process -> getPid ( ) -> onResolve ( function ( $ error , $ pid ) { if ( $ error ) { throw new ProcessException ( $ error ) ; } print "\nStopping Process Id: {$pid}\n" ; if ( '\\' === \ DIRECTORY_SEPARATOR ) { \ exec ( \ sprintf ( 'taskkill /F /T /PID %d 2>&1' , $ pid ) , $ o... | Stop the running process |
55,255 | public function start ( ) : int { $ scripts = $ this -> installManager -> install ( ) ; $ this -> processRunner = new ProcessRunner ( $ scripts -> getMockService ( ) , $ this -> getArguments ( ) ) ; $ processId = $ this -> processRunner -> run ( ) ; $ this -> verifyHealthCheck ( ) ; return $ processId ; } | Start the Mock Server . Verify that it is running . |
55,256 | private function verifyHealthCheck ( ) : bool { $ service = $ this -> httpService ; $ tries = 0 ; $ maxTries = $ this -> config -> getHealthCheckTimeout ( ) ; do { ++ $ tries ; try { $ status = $ service -> healthCheck ( ) ; return $ status ; } catch ( ConnectException $ e ) { \ sleep ( 1 ) ; } } while ( $ tries <= $ m... | Make sure the server starts as expected . |
55,257 | public function Build ( ) { $ obj = new \ stdClass ( ) ; $ obj -> metadata = $ this -> metadata ; $ obj -> contents = $ this -> contents ; return \ json_encode ( $ obj ) ; } | Build metadata and content for message |
55,258 | public function addCallback ( string $ key , callable $ callback ) : self { if ( ! isset ( $ this -> callbacks [ $ key ] ) ) { $ this -> callbacks [ $ key ] = $ callback ; } else { throw new \ Exception ( "Callback with key ($key) already exists" ) ; } return $ this ; } | Add an individual call back |
55,259 | public function reify ( Message $ pact ) : string { $ scripts = $ this -> installManager -> install ( ) ; $ json = \ json_encode ( $ pact ) ; $ process = new ProcessRunner ( $ scripts -> getPactMessage ( ) , [ 'reify' , "'" . $ json . "'" ] ) ; $ process -> runBlocking ( ) ; $ output = $ process -> getOutput ( ) ; \ pr... | Build an example from the data structure back into its generated form i . e . strip out all of the matchers etc |
55,260 | public function update ( string $ pactJson , string $ consumer , string $ provider , string $ pactDir ) : bool { $ scripts = $ this -> installManager -> install ( ) ; $ arguments = [ ] ; $ arguments [ ] = 'update' ; $ arguments [ ] = "--consumer={$consumer}" ; $ arguments [ ] = "--provider={$provider}" ; $ arguments [ ... | Update a pact with the given message or create the pact if it does not exist . The MESSAGE_JSON may be in the legacy Ruby JSON format or the v2 + format . |
55,261 | public function registerMessage ( Message $ message ) : bool { $ uri = $ this -> config -> getBaseUri ( ) -> withPath ( '/interactions' ) ; $ body = \ json_encode ( $ message -> jsonSerialize ( ) ) ; $ this -> client -> post ( $ uri , [ 'headers' => [ 'Content-Type' => 'application/json' , 'X-Pact-Mock-Service' => true... | Separate function for messages instead of interactions as I am unsure what to do with the Ruby Standalone at the moment |
55,262 | public function disconnect ( string $ name = null ) { $ name = $ name ? : $ this -> getDefaultConnection ( ) ; unset ( $ this -> connections [ $ name ] ) ; } | Disconnect from the given connection . |
55,263 | public function extend ( string $ name , callable $ resolver ) { if ( $ resolver instanceof Closure ) { $ this -> extensions [ $ name ] = $ resolver -> bindTo ( $ this , $ this ) ; } else { $ this -> extensions [ $ name ] = $ resolver ; } } | Register an extension connection resolver . |
55,264 | public function getOptions ( ) { $ result = [ ] ; foreach ( $ this -> options as $ option ) { $ value = $ option -> getValue ( ) ; if ( $ value !== null ) { $ result [ $ option -> getShort ( ) ? : $ option -> getLong ( ) ] = $ value ; if ( $ short = $ option -> getShort ( ) ) { $ result [ $ short ] = $ value ; } if ( $... | Returns the list of options with a value . |
55,265 | public function getCommand ( $ name = null ) { if ( $ name !== null ) { return isset ( $ this -> commands [ $ name ] ) ? $ this -> commands [ $ name ] : null ; } return $ this -> command ; } | Get the current or a named command . |
55,266 | protected function nextOperand ( ) { if ( isset ( $ this -> operands [ $ this -> operandsCount ] ) ) { $ operand = $ this -> operands [ $ this -> operandsCount ] ; if ( ! $ operand -> isMultiple ( ) ) { $ this -> operandsCount ++ ; } return $ operand ; } return null ; } | Get the next operand |
55,267 | public static function fromString ( $ argsString ) { $ argv = [ '' ] ; $ argsString = trim ( $ argsString ) ; $ argc = 0 ; if ( empty ( $ argsString ) ) { return new self ( [ ] ) ; } $ state = 'n' ; for ( $ i = 0 ; $ i < strlen ( $ argsString ) ; $ i ++ ) { $ char = $ argsString { $ i } ; switch ( $ state ) { case 'n' ... | Parse arguments from argument string |
55,268 | public function setMode ( $ mode ) { if ( ! in_array ( $ mode , [ GetOpt :: NO_ARGUMENT , GetOpt :: OPTIONAL_ARGUMENT , GetOpt :: REQUIRED_ARGUMENT , GetOpt :: MULTIPLE_ARGUMENT , ] , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Option mode must be one of %s, %s, %s and %s' , 'GetOpt::NO_ARGUMENT' , 'Ge... | Change the mode |
55,269 | public function describe ( ) { return $ this -> option ? $ this -> option -> describe ( ) : sprintf ( '%s \'%s\'' , GetOpt :: translate ( static :: TRANSLATION_KEY ) , $ this -> getName ( ) ) ; } | Returns a human readable string representation of the object |
55,270 | public function conflicts ( Option $ option ) { $ short = $ option -> getShort ( ) ; $ long = $ option -> getLong ( ) ; return $ short && isset ( $ this -> optionMapping [ $ short ] ) || $ long && isset ( $ this -> optionMapping [ $ long ] ) ; } | Check if option conflicts with defined options . |
55,271 | protected function generate ( $ bundleName , array $ configuration , $ output ) { $ processed = false ; foreach ( $ this -> getContainer ( ) -> get ( 'kernel' ) -> getBundles ( ) as $ bundle ) { if ( $ bundle -> getName ( ) !== $ bundleName ) { continue ; } $ processed = true ; $ bundleMetadata = new BundleMetadata ( $... | Generates a bundle entities from a bundle name . |
55,272 | final public function addOverride ( $ class , $ type , array $ options ) { if ( ! isset ( $ this -> overrides [ $ class ] ) ) { $ this -> overrides [ $ class ] = [ ] ; } if ( ! isset ( $ this -> overrides [ $ class ] [ $ type ] ) ) { $ this -> overrides [ $ class ] [ $ type ] = [ ] ; } $ this -> overrides [ $ class ] [... | Adds new override . |
55,273 | final public function addOverride ( $ class , $ type , array $ options ) { if ( ! isset ( $ this -> overrides [ $ class ] ) ) { $ this -> overrides [ $ class ] = [ ] ; } $ this -> overrides [ $ class ] [ $ type ] = $ options ; } | Adds new ORM override . |
55,274 | protected function copyResultFile ( $ handler , $ file ) { if ( ! is_file ( $ file ) ) { throw new \ OutOfBoundsException ( "Result file $file is not readable" ) ; } $ extension = 'xml' ; if ( preg_match ( '(\.([a-z]+)$)' , $ file , $ match ) ) { $ extension = $ match [ 1 ] ; } copy ( $ file , $ this -> targetDir . '/'... | Copy result file |
55,275 | protected function getDefaultCommands ( ) { $ shell = new Shell ( dirname ( VENDOR_PATH ) ) ; $ handlers = [ 'source' => new Handler \ Source ( $ shell ) , 'coverage' => new Handler \ Coverage ( ) , 'pdepend' => new Handler \ PDepend ( $ shell ) , 'dependencies' => new Handler \ Dependencies ( $ shell ) , 'phpmd' => ne... | Get default commands |
55,276 | public function exec ( $ command , array $ arguments = [ ] , array $ okCodes = [ 0 ] , $ workingDir = null ) { $ command = $ this -> makeAbsolute ( $ command ) ; $ escapedCommand = escapeshellcmd ( $ command ) . ' ' . implode ( ' ' , array_map ( 'escapeshellarg' , $ arguments ) ) ; $ originalWorkingDir = getcwd ( ) ; c... | Exec shell command |
55,277 | protected function countGitChangesPerFileRange ( Project $ project , $ file , $ from , $ to ) { $ options = [ 'log' , '--format=format:qacommit: %H' , '--no-patch' , '-L' , "$from,$to:$file" , ] ; $ existingResults = $ this -> shell -> exec ( 'git' , $ options , [ 0 ] , $ project -> baseDir ) ; return count ( array_fil... | Counts GIT commits per file and range . This is used to track the number of commits on methods or classes . |
55,278 | protected static function getErrorMessage ( $ code ) { $ string = socket_strerror ( $ code ) ; foreach ( get_defined_constants ( ) as $ key => $ value ) { if ( $ value === $ code && strpos ( $ key , 'SOCKET_' ) === 0 ) { $ string .= ' (' . $ key . ')' ; break ; } } return $ string ; } | get error message for given error code |
55,279 | public function accept ( ) { $ resource = @ socket_accept ( $ this -> resource ) ; if ( $ resource === false ) { throw Exception :: createFromGlobalSocketOperation ( ) ; } return new Socket ( $ resource ) ; } | accept an incomming connection on this listening socket |
55,280 | public function connect ( $ address ) { $ ret = @ socket_connect ( $ this -> resource , $ this -> unformatAddress ( $ address , $ port ) , $ port ) ; if ( $ ret === false ) { throw Exception :: createFromSocketResource ( $ this -> resource ) ; } return $ this ; } | initiate a connection to given address |
55,281 | public function getOption ( $ level , $ optname ) { $ value = @ socket_get_option ( $ this -> resource , $ level , $ optname ) ; if ( $ value === false ) { throw Exception :: createFromSocketResource ( $ this -> resource ) ; } return $ value ; } | get socket option |
55,282 | public function listen ( $ backlog = 0 ) { $ ret = @ socket_listen ( $ this -> resource , $ backlog ) ; if ( $ ret === false ) { throw Exception :: createFromSocketResource ( $ this -> resource ) ; } return $ this ; } | start listen for incoming connections |
55,283 | public function setOption ( $ level , $ optname , $ optval ) { $ ret = @ socket_set_option ( $ this -> resource , $ level , $ optname , $ optval ) ; if ( $ ret === false ) { throw Exception :: createFromSocketResource ( $ this -> resource ) ; } return $ this ; } | set socket option |
55,284 | public function shutdown ( $ how = 2 ) { $ ret = @ socket_shutdown ( $ this -> resource , $ how ) ; if ( $ ret === false ) { throw Exception :: createFromSocketResource ( $ this -> resource ) ; } return $ this ; } | shuts down socket for receiving sending or both |
55,285 | public function assertAlive ( ) { $ code = $ this -> getOption ( SOL_SOCKET , SO_ERROR ) ; if ( $ code !== 0 ) { throw Exception :: createFromCode ( $ code , 'Socket error' ) ; } return $ this ; } | assert that this socket is alive and its error code is 0 |
55,286 | protected function unformatAddress ( $ address , & $ port ) { $ colon = strrpos ( $ address , ':' ) ; if ( $ colon !== false && ( strpos ( $ address , ':' ) === $ colon || strpos ( $ address , ']' ) === ( $ colon - 1 ) ) ) { $ port = ( int ) substr ( $ address , $ colon + 1 ) ; $ address = substr ( $ address , 0 , $ co... | format given address by splitting it into returned address and port set by reference |
55,287 | public function createClient ( $ address , $ timeout = null ) { $ socket = $ this -> createFromString ( $ address , $ scheme ) ; try { if ( $ timeout === null ) { $ socket -> connect ( $ address ) ; } else { $ socket -> connectTimeout ( $ address , $ timeout ) ; $ socket -> setBlocking ( true ) ; } } catch ( Exception ... | create client socket connected to given target address |
55,288 | public function create ( $ domain , $ type , $ protocol ) { $ sock = @ socket_create ( $ domain , $ type , $ protocol ) ; if ( $ sock === false ) { throw Exception :: createFromGlobalSocketOperation ( 'Unable to create socket' ) ; } return new Socket ( $ sock ) ; } | create low level socket with given arguments |
55,289 | public function createFromString ( & $ address , & $ scheme ) { if ( $ scheme === null ) { $ scheme = 'tcp' ; } $ hasScheme = false ; $ pos = strpos ( $ address , '://' ) ; if ( $ pos !== false ) { $ scheme = substr ( $ address , 0 , $ pos ) ; $ address = substr ( $ address , $ pos + 3 ) ; $ hasScheme = true ; } if ( s... | create socket for given address |
55,290 | public function getHeight ( ) { if ( $ this -> isLeaf ( ) ) { return 0 ; } $ heights = [ ] ; foreach ( $ this -> getChildren ( ) as $ child ) { $ heights [ ] = $ child -> getHeight ( ) ; } return max ( $ heights ) + 1 ; } | Return the height of the tree whose root is this node |
55,291 | public function getSize ( ) { $ size = 1 ; foreach ( $ this -> getChildren ( ) as $ child ) { $ size += $ child -> getSize ( ) ; } return $ size ; } | Return the number of nodes in a tree |
55,292 | protected function updateSubscriptionsToPaymentMethod ( $ token ) { foreach ( $ this -> subscriptions as $ subscription ) { if ( $ subscription -> active ( ) ) { BraintreeSubscription :: update ( $ subscription -> braintree_id , [ 'paymentMethodToken' => $ token , ] ) ; } } } | Update the payment method token for all of the model s subscriptions . |
55,293 | public function paymentMethod ( ) { $ customer = $ this -> asBraintreeCustomer ( ) ; foreach ( $ customer -> paymentMethods as $ paymentMethod ) { if ( $ paymentMethod -> isDefault ( ) ) { return $ paymentMethod ; } } } | Get the default payment method for the customer . |
55,294 | public function subscribedToPlan ( $ plans , $ subscription = 'default' ) { $ subscription = $ this -> subscription ( $ subscription ) ; if ( ! $ subscription || ! $ subscription -> valid ( ) ) { return false ; } foreach ( ( array ) $ plans as $ plan ) { if ( $ subscription -> braintree_plan === $ plan ) { return true ... | Determine if the model is actively subscribed to one of the given plans . |
55,295 | public function createAsBraintreeCustomer ( $ token , array $ options = [ ] ) : Customer { $ response = BraintreeCustomer :: create ( array_replace_recursive ( [ 'firstName' => Arr :: get ( explode ( ' ' , $ this -> name ) , 0 ) , 'lastName' => Arr :: get ( explode ( ' ' , $ this -> name ) , 1 ) , 'email' => $ this -> ... | Create a Braintree customer for the given model . |
55,296 | public function addOnAmount ( ) { $ totalAddOn = 0 ; foreach ( $ this -> transaction -> addOns as $ addOn ) { $ totalAddOn += $ addOn -> amount * ( $ addOn -> quantity ?? 1 ) ; } return ( float ) $ totalAddOn ; } | Get the raw add - on amount . |
55,297 | public function addOns ( ) { $ addOns = [ ] ; foreach ( $ this -> transaction -> addOns as $ addOn ) { $ addOns [ ] = $ addOn -> id ; } return $ addOns ; } | Get the add - on codes applied to the invoice . |
55,298 | public function discountAmount ( ) { $ totalDiscount = 0 ; foreach ( $ this -> transaction -> discounts as $ discount ) { $ totalDiscount += $ discount -> amount ; } return ( float ) $ totalDiscount ; } | Get the raw discount amount . |
55,299 | public function coupons ( ) { $ coupons = [ ] ; foreach ( $ this -> transaction -> discounts as $ discount ) { $ coupons [ ] = $ discount -> id ; } return $ coupons ; } | Get the coupon codes applied to the invoice . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.