idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
52,500 | static function getDatepickerLanguage ( $ in_format ) { $ retval = "" ; switch ( $ in_format ) { case "en-GB" : $ retval = "en-GB" ; break ; case "ar-DZ" : $ retval = "ar-DZ" ; break ; case "en-AU" : $ retval = "en-AU" ; break ; case "en-NZ" : $ retval = "en-NZ" ; break ; case "fr-CN" : $ retval = "fr-CH" ; break ; cas... | for loading the apprpriate data picket |
52,501 | static function getDatepickerFormat ( $ in_format ) { $ retval = "" ; switch ( $ in_format ) { case "d-m-Y" : $ retval = "dd-mm-yy" ; break ; case "d/m/Y" : $ retval = "dd/mm/yy" ; break ; case "m/d/Y" : $ retval = "mm/dd/yy" ; break ; case "m-d-Y" : $ retval = "mm-dd-yy" ; break ; case "Y/m/d" : $ retval = "yy/mm/dd" ... | for the JUI date picker routine |
52,502 | static function dbCharsetToPhpCharset ( $ in ) { $ out = $ in ; switch ( $ in ) { case "None" : $ out = false ; break ; case "UTF8" : $ out = "UTF-8" ; break ; case "LATIN1" : $ out = "ISO-8859-1" ; break ; case "LATIN2" : $ out = "ISO-8859-2" ; break ; case "LATIN3" : $ out = "ISO-8859-3" ; break ; case "LATIN4" : $ o... | Takes project config db encoding and converts it to PHP representation for iconv |
52,503 | static function outputCharsetToPhpCharset ( $ in ) { $ out = $ in ; switch ( $ in ) { case "None" : $ out = false ; break ; case "UTF8" : $ out = "UTF-8" ; break ; case "ISO-8859-1" : case "ISO-8859-2" : case "ISO-8859-3" : case "ISO-8859-4" : case "ISO-8859-5" : case "ISO-8859-6" : case "ISO-8859-7" : case "ISO-8859-8... | Takes project config output encoding and converts it to PHP representation for iconv |
52,504 | static function getOutputEncodingHtml ( ) { $ txt = '' ; $ tmp1 = '<meta http-equiv="Content-Type" content="text/html; charset=' ; $ tmp2 = '" />' ; switch ( ReporticoApp :: getConfig ( "output_encoding" ) ) { case "None" : $ txt = '' ; break ; case "UTF8" : $ txt = $ tmp1 . "utf-8" . $ tmp2 ; '<meta charset="utf-8">' ... | Gets HTML META tag for setting HTML encoding based on project SW_OUTPUT_ENCODING tag |
52,505 | public function & createGraph ( ) { $ engine = $ this -> charting_engine ; if ( $ this -> target_format == "HTML" || $ this -> target_format == "HTML2PDF" ) { $ engine = $ this -> charting_engine_html ; } if ( ReporticoUtility :: getRequestItem ( "target_format" , "HTML" ) == "PDF" ) { $ engine = $ this -> charting_eng... | End Yii functions |
52,506 | public function deriveAjaxOperation ( ) { $ sessionClass = ReporticoSession ( ) ; $ this -> reportico_url_path = ReporticoUtility :: getReporticoUrlPath ( ) ; if ( ! $ this -> url_path_to_reportico_runner ) { $ this -> url_path_to_reportico_runner = $ this -> reportico_url_path . "run.php" ; } $ sessionClass :: registe... | url request parameter |
52,507 | public function getTemplatePath ( $ template ) { $ reportname = preg_replace ( "/.xml/" , "" , $ this -> xmloutfile . '_' . $ template ) ; if ( preg_match ( "/$reportname/" , ReporticoUtility :: findBestLocationInIncludePath ( "templates/" . $ this -> getTheme ( ) . $ reportname ) ) ) { $ template = $ reportname ; } if... | Get the path to the template |
52,508 | function fetch ( $ template_file ) { $ template = $ this -> twig -> load ( $ template_file ) ; return $ template -> render ( $ this -> twig_vars ) ; } | Assign a template variable |
52,509 | static function setUpReporticoSession ( $ namespace ) { $ session_name = session_id ( ) ; if ( isset ( $ _REQUEST [ 'reportico_session_name' ] ) ) { $ session_name = $ _REQUEST [ 'reportico_session_name' ] ; if ( preg_match ( "/_/" , $ session_name ) ) { $ ar = explode ( "_" , $ session_name ) ; ReporticoApp :: set ( "... | target separate SESSION_ID |
52,510 | static function issetReporticoSessionParam ( $ param , $ session_name = false ) { if ( ! $ session_name ) $ session_name = ReporticoApp :: get ( "session_namespace_key" ) ; return isset ( $ _SESSION [ $ session_name ] [ $ param ] ) ; } | Check if a particular reeportico session parameter is set using current session namespace |
52,511 | static function setReporticoSessionParam ( $ param , $ value , $ namespace = false , $ array = false ) { if ( ! $ namespace ) $ namespace = ReporticoApp :: get ( "session_namespace_key" ) ; if ( ! $ array ) { $ _SESSION [ $ namespace ] [ $ param ] = $ value ; } else { $ _SESSION [ $ namespace ] [ $ array ] [ $ param ] ... | Sets a reportico session_param using current session namespace |
52,512 | static function getReporticoSessionParam ( $ param ) { if ( self :: issetReporticoSessionParam ( $ param ) ) return $ _SESSION [ ReporticoApp :: get ( "session_namespace_key" ) ] [ $ param ] ; else return false ; } | Return the value of a reportico session_param using current session namespace |
52,513 | static function unsetReporticoSessionParam ( $ param ) { if ( isset ( $ _SESSION [ ReporticoApp :: get ( "session_namespace_key" ) ] [ $ param ] ) ) { unset ( $ _SESSION [ ReporticoApp :: get ( "session_namespace_key" ) ] [ $ param ] ) ; } } | Clears a reportico session_param using current session namespace |
52,514 | static function loadModeLanguagePack ( $ mode , $ output_encoding = "utf-8" , $ replace = false ) { $ langfile = ReporticoUtility :: findBestLocationInIncludePath ( "language" ) ; if ( ReporticoApp :: isSetConfig ( "SW_OUTPUT_ENCODING" ) && ReporticoApp :: getConfig ( "SW_OUTPUT_ENCODING" ) != "UTF8" && is_dir ( $ lang... | Load the relevant localisation strings from the language folder |
52,515 | static function loadProjectLanguagePack ( $ project , $ output_encoding = "utf-8" ) { ReporticoApp :: set ( "translations" , array ( ) ) ; $ langfile = "projects/$project/lang_" . ReporticoApp :: getConfig ( "language" ) . ".php" ; if ( is_file ( $ langfile ) ) { include $ langfile ; } else { ReporticoUtility :: findFi... | Load the users custom translations strings from the project |
52,516 | static function localiseTemplateStrings ( & $ in_template ) { $ local = ReporticoApp :: get ( "locale" ) ; if ( $ local ) { foreach ( $ local [ "template" ] as $ key => $ string ) { $ in_template -> assign ( $ key , $ string ) ; } } $ in_template -> assign ( "OUTPUT_ENCODING" , ReporticoLocale :: getOutputEncodingHtml ... | Set local language strings in templates |
52,517 | static function templateXlate ( $ in_string ) { if ( ! $ in_string ) { return $ in_string ; } $ out_string = "T_" . $ in_string ; $ local = ReporticoApp :: get ( "locale" ) ; if ( $ local ) { if ( array_key_exists ( $ out_string , $ local [ "template" ] ) ) { $ out_string = $ local [ "template" ] [ $ out_string ] ; } e... | Fetched translation for a template string |
52,518 | static function availableLanguages ( ) { $ langs = array ( ) ; $ lang_dir = ReporticoUtility :: findBestLocationInIncludePath ( "language" ) ; if ( is_dir ( $ lang_dir ) ) { if ( $ dh = opendir ( $ lang_dir ) ) { while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( $ file == "en_gb" || $ file == "en_us" ) { if ( is... | Used to generate language selection box |
52,519 | public function removeFile ( $ filename ) { if ( ! $ filename ) { trigger_error ( ReporticoLang :: templateXlate ( "UNABLE_TO_REMOVE" ) . templateXlate ( "SPECIFYXML" ) , E_USER_ERROR ) ; return false ; } if ( ! preg_match ( "/\.xml$/" , $ filename ) ) { $ filename = $ filename . ".xml" ; } $ projdir = $ this -> query ... | Remove report XML from disk |
52,520 | public function writeFile ( $ filename ) { if ( ! $ filename ) { trigger_error ( ReporticoLang :: templateXlate ( "UNABLE_TO_SAVE" ) . templateXlate ( "SPECIFYXML" ) , E_USER_ERROR ) ; return false ; } if ( ! preg_match ( "/\.xml$/" , $ filename ) ) { $ filename = $ filename . ".xml" ; } $ projdir = $ this -> query -> ... | Save report XML to disk |
52,521 | protected function getLanguageMapper ( ) : LanguageMapper { if ( null === $ this -> languageMapper ) { $ this -> languageMapper = new LanguageMapper ( ) ; } return $ this -> languageMapper ; } | Return language mapper . |
52,522 | protected function parseOutput ( string $ output ) : array { $ lines = explode ( PHP_EOL , $ output ) ; $ issues = [ ] ; $ lineNo = 1 ; foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; if ( '' === $ line ) { $ lineNo ++ ; continue ; } switch ( $ line [ 0 ] ) { case '#' : $ parts = explode ( ' ' , $ line ) ; $... | Parse ispell output . |
52,523 | private function getDictionaryFolder ( ) : string { if ( null === $ this -> bundledDictFolder ) { $ binary = $ this -> getBinary ( ) ; if ( realpath ( $ binary ) === false ) { $ process = new Process ( [ 'which ' . $ this -> getBinary ( ) ] ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { throw new E... | Return path to folder with bundled ispell dictionaries . |
52,524 | protected function createDomDocument ( $ html ) : \ DOMDocument { $ document = new \ DOMDocument ( '1.0' ) ; $ previousValue = libxml_use_internal_errors ( true ) ; libxml_clear_errors ( ) ; $ document -> loadHTML ( $ html ) ; $ errors = libxml_get_errors ( ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ p... | Create DOMDocument from HTML string . |
52,525 | public function setDictionaryPath ( string $ path ) : void { $ this -> customDictPath = $ path ; $ this -> supportedLanguages = null ; } | Set additional dictionaries path . |
52,526 | protected function createEnvVars ( EncodingAwareSource $ source , array $ languages ) : array { $ vars = [ ] ; if ( $ this -> customDictPath ) { $ vars [ 'DICPATH' ] = $ this -> customDictPath ; } return $ vars ; } | Create environment variables for external speller . |
52,527 | public function checkText ( EncodingAwareSource $ source , array $ languages ) : array { $ process = $ this -> createProcess ( $ this -> createArguments ( $ source , $ languages ) ) ; $ process -> setEnv ( $ this -> createEnvVars ( $ source , $ languages ) ) ; $ process -> setInput ( $ source -> getAsString ( ) ) ; try... | Check text . |
52,528 | protected function composeCommand ( $ args ) : string { $ command = $ this -> getBinary ( ) ; if ( \ is_array ( $ args ) ) { $ args = implode ( ' ' , $ args ) ; } $ command .= $ args !== '' ? ' ' . $ args : '' ; return $ command ; } | Compose shell command line |
52,529 | protected function createProcess ( $ args = null ) : Process { $ command = $ this -> composeCommand ( $ args ) ; try { $ process = $ this -> composeProcess ( $ command ) ; } catch ( RuntimeException $ e ) { throw new ExternalProgramFailedException ( $ command , $ e -> getMessage ( ) , 0 , $ e ) ; } return $ process ; } | Create new instance of external program . |
52,530 | private function composeProcess ( string $ command ) : Process { if ( $ this -> process === null ) { $ this -> process = new Process ( [ $ command ] ) ; } $ this -> process -> inheritEnvironmentVariables ( ) ; $ this -> process -> setTimeout ( $ this -> timeout ) ; $ this -> process -> setCommandLine ( $ command ) ; re... | Compose a process with given command . If no process is given in current instance a new one will be created . |
52,531 | public function getAsString ( ) : string { $ text = iconv ( $ this -> source -> getEncoding ( ) , $ this -> getEncoding ( ) , $ this -> source -> getAsString ( ) ) ; if ( false === $ text ) { throw new SourceException ( 'iconv failed to convert source text' ) ; } return $ text ; } | Return text in the specified encoding . |
52,532 | public function filter ( string $ string ) : string { $ result = '' ; $ string = $ this -> filterEntities ( $ string ) ; $ string = $ this -> filterMetaTags ( $ string ) ; $ tagName = null ; $ attrName = null ; $ context = self :: CTX_TAG_CONTENT ; $ expecting = null ; $ ignoreTagContent = false ; $ ignoreAttrValue = t... | Filter string . |
52,533 | private function filterEntities ( string $ string ) : string { return preg_replace_callback ( '/&\w+;/' , function ( $ match ) { return str_repeat ( ' ' , strlen ( $ match [ 0 ] ) ) ; } , $ string ) ; } | Replace HTML entities . |
52,534 | private function filterMetaTags ( string $ string ) : string { return preg_replace_callback ( '/<meta[^>]+(http-equiv\s*=|name\s*=\s*["\']?([^>"\']+))[^>]*>/i' , function ( $ match ) { if ( count ( $ match ) < 3 || ! in_array ( strtolower ( $ match [ 2 ] ) , self :: $ textMetaTags , true ) ) { return str_repeat ( ' ' ,... | Replace non - text meta tags . |
52,535 | public function map ( array $ requested , array $ supported ) : array { $ index = [ ] ; foreach ( $ supported as $ tag ) { $ key = strtolower ( preg_replace ( '/_-\./' , '' , $ tag ) ) ; $ index [ $ key ] = $ tag ; } $ result = [ ] ; foreach ( $ requested as $ source ) { if ( array_key_exists ( $ source , $ this -> pre... | Map given list of language tags to supported ones |
52,536 | public function setPreferredMappings ( array $ mappings ) : void { foreach ( $ mappings as $ language => $ map ) { $ this -> preferred [ $ language ] = ( array ) $ map ; } } | Set preferred mappings |
52,537 | public function addFilter ( string $ pattern , Filter $ filter = null ) : void { $ this -> filters [ $ pattern ] = $ filter ; } | Add custom pattern to be filtered . |
52,538 | protected function getClamavSocket ( ) { if ( file_exists ( env ( 'CLAMAV_UNIX_SOCKET' , self :: CLAMAV_UNIX_SOCKET ) ) ) { return 'unix://' . env ( 'CLAMAV_UNIX_SOCKET' , self :: CLAMAV_UNIX_SOCKET ) ; } return env ( 'CLAMAV_TCP_SOCKET' , self :: CLAMAV_LOCAL_TCP_SOCKET ) ; } | Guess the ClamAV socket |
52,539 | protected function getFilePath ( $ file ) { if ( $ file instanceof UploadedFile ) { return $ file -> getPathname ( ) ; } if ( is_array ( $ file ) && null !== array_get ( $ file , 'tmp_name' ) ) { return $ file [ 'tmp_name' ] ; } return $ file ; } | Return the file path from the passed object |
52,540 | public static function guardAgainstInvalidAlpha2 ( $ alpha2 ) { if ( ! is_string ( $ alpha2 ) ) { throw new InvalidArgumentException ( sprintf ( 'Expected $alpha2 to be of type string, got: %s' , gettype ( $ alpha2 ) ) ) ; } if ( ! preg_match ( '/^[a-zA-Z]{2}$/' , $ alpha2 ) ) { throw new DomainException ( sprintf ( 'N... | Assert that input looks like an alpha2 key . |
52,541 | public static function guardAgainstInvalidAlpha3 ( $ alpha3 ) { if ( ! is_string ( $ alpha3 ) ) { throw new InvalidArgumentException ( sprintf ( 'Expected $alpha3 to be of type string, got: %s' , gettype ( $ alpha3 ) ) ) ; } if ( ! preg_match ( '/^[a-zA-Z]{3}$/' , $ alpha3 ) ) { throw new DomainException ( sprintf ( 'N... | Assert that input looks like an alpha3 key . |
52,542 | public static function guardAgainstInvalidNumeric ( $ numeric ) { if ( ! is_string ( $ numeric ) ) { throw new InvalidArgumentException ( sprintf ( 'Expected $numeric to be of type string, got: %s' , gettype ( $ numeric ) ) ) ; } if ( ! preg_match ( '/^[0-9]{3}$/' , $ numeric ) ) { throw new DomainException ( sprintf (... | Assert that input looks like a numeric key . |
52,543 | public static function getRegion ( $ locale ) { $ parts = explode ( '-' , str_replace ( '_' , '-' , $ locale ) ) ; if ( count ( $ parts ) === 1 ) { return '' ; } $ region = end ( $ parts ) ; if ( strlen ( $ region ) === 4 ) { return '' ; } if ( $ region === 'POSIX' ) { $ region = 'US' ; } return strtoupper ( $ region )... | Get the region for the input locale |
52,544 | public static function getDisplayRegion ( $ locale , $ inLocale ) { $ dataDir = __DIR__ . DIRECTORY_SEPARATOR . static :: $ dataDir ; $ region = static :: getRegion ( $ locale ) ; $ regionList = require $ dataDir . '_list.php' ; $ fallbackParts = explode ( '-' , str_replace ( '_' , '-' , $ inLocale ) ) ; $ filesToSearc... | Get the localised display name for the region of the input locale |
52,545 | public static function getAllCountriesForLocale ( $ locale ) { $ dataDir = __DIR__ . DIRECTORY_SEPARATOR . static :: $ dataDir ; $ regionList = require $ dataDir . '_list.php' ; if ( ! isset ( $ regionList [ $ locale ] ) ) { throw new \ RuntimeException ( "Locale is not supported" ) ; } $ fallbackParts = explode ( '-' ... | Load a list of all countries supported by a particular Locale |
52,546 | private function checkDirectories ( $ inputDir , $ outputDir ) { if ( ! is_dir ( $ inputDir ) ) { throw new InvalidArgumentException ( sprintf ( "Unable to find input directory: %s" , $ inputDir ) ) ; } if ( ! is_dir ( $ outputDir ) ) { if ( mkdir ( $ outputDir ) === false ) { throw new RuntimeException ( sprintf ( "Un... | Check and create directories |
52,547 | private function loadLocales ( $ inputDir ) { $ localeList = array ( ) ; foreach ( scandir ( $ inputDir ) as $ item ) { if ( substr ( $ item , 0 , 1 ) !== '.' && is_dir ( $ inputDir . $ item ) ) { if ( in_array ( $ item , $ this -> ignoredLocales ) ) { continue ; } $ localeList [ ] = $ item ; } } return $ localeList ; ... | Load Locale list from the source data |
52,548 | public function getScore ( int $ maxCommits , int $ maxComplexity ) : float { Assert :: greaterThan ( $ maxComplexity , 0 ) ; Assert :: greaterThan ( $ maxCommits , 0 ) ; $ horizontalDistance = $ maxCommits - $ this -> getCommits ( ) ; $ verticalDistance = $ maxComplexity - $ this -> getComplexity ( ) ; $ normalizedHor... | Calculate the score . |
52,549 | public function parse ( Collection $ completedProcesses ) : ResultCollection { $ this -> resultsCollection = new ResultCollection ; foreach ( $ completedProcesses as $ file => $ processes ) { $ this -> parseCompletedProcessesForFile ( $ file , $ processes ) ; } return $ this -> resultsCollection ; } | Turns a collection of completed processes into a collection of parsed result objects . |
52,550 | private function parseCompletedProcessesForFile ( string $ file , array $ processes ) { $ commits = ( integer ) $ this -> parseCommits ( $ processes [ 'GitCommitProcess' ] ) ; $ complexity = ( integer ) $ processes [ 'CyclomaticComplexityProcess' ] -> getOutput ( ) ; $ result = new Result ( [ 'file' => $ file , 'commit... | Parse the list of processes for a file . |
52,551 | private function parseCommits ( ChurnProcess $ process ) : int { $ output = $ process -> getOutput ( ) ; preg_match ( "/([0-9]{1,})/" , $ output , $ matches ) ; if ( ! isset ( $ matches [ 1 ] ) ) { return 0 ; } return ( integer ) $ matches [ 1 ] ; } | Parse the number of commits on the file from the raw process output . |
52,552 | private function getDirectoriesToScan ( InputInterface $ input , array $ dirsConfigured ) : array { $ dirsProvidedAsArgs = $ input -> getArgument ( 'paths' ) ; if ( count ( $ dirsProvidedAsArgs ) > 0 ) { return $ dirsProvidedAsArgs ; } if ( count ( $ dirsConfigured ) > 0 ) { return $ dirsConfigured ; } throw new Invali... | Get the directories to scan . |
52,553 | public function process ( Collection $ completedProcesses , float $ minScore , int $ filesToShow ) : ResultCollection { $ resultCollection = $ this -> parser -> parse ( $ completedProcesses ) ; $ resultCollection = $ resultCollection -> whereScoreAbove ( $ minScore ) ; $ resultCollection = $ resultCollection -> orderBy... | Processes the results into a ResultCollection . |
52,554 | private function fileShouldBeIgnored ( SplFileInfo $ file ) : bool { foreach ( $ this -> filesToIgnore as $ fileToIgnore ) { $ regex = $ this -> patternToRegex ( $ fileToIgnore ) ; if ( preg_match ( "#{$regex}#" , $ file -> getPathName ( ) ) ) { return true ; } } return false ; } | Determines if a file should be ignored . |
52,555 | public function orderByScoreDesc ( ) : self { return $ this -> sortByDesc ( function ( Result $ result ) { return $ result -> getScore ( $ this -> maxCommits ( ) , $ this -> maxComplexity ( ) ) ; } ) ; } | Order results by their score in descending order . |
52,556 | public function assess ( string $ filePath ) : int { $ this -> score = 0 ; $ contents = $ this -> getFileContents ( $ filePath ) ; $ this -> hasAtLeastOneMethod ( $ contents ) ; $ this -> countTheIfStatements ( $ contents ) ; $ this -> countTheElseIfStatements ( $ contents ) ; $ this -> countTheWhileLoops ( $ contents ... | Asses the files cyclomatic complexity . |
52,557 | protected function hasAtLeastOneMethod ( string $ contents ) { preg_match ( "/[ ]function[ ]/" , $ contents , $ matches ) ; if ( isset ( $ matches [ 0 ] ) ) { $ this -> score ++ ; } } | Does the class have at least one method? |
52,558 | public function process ( FileCollection $ filesCollection , ProcessFactory $ processFactory , int $ numberOfParallelJobs ) : Collection { $ this -> filesCollection = $ filesCollection ; $ this -> processFactory = $ processFactory ; $ this -> runningProcesses = new Collection ; $ this -> completedProcessesArray = [ ] ;... | Run the processes to gather information . |
52,559 | private function getProcessResults ( int $ numberOfParallelJobs ) { for ( $ index = $ this -> runningProcesses -> count ( ) ; $ this -> filesCollection -> hasFiles ( ) > 0 && $ index < $ numberOfParallelJobs ; $ index ++ ) { $ file = $ this -> filesCollection -> getNextFile ( ) ; $ process = $ this -> processFactory ->... | Get the results of the processes . |
52,560 | public function getRenderer ( string $ format ) : ResultsRendererInterface { if ( $ format === self :: FORMAT_CSV ) { return new CsvResultsRenderer ; } if ( $ format === self :: FORMAT_JSON ) { return new JsonResultsRenderer ; } if ( $ format === self :: FORMAT_TEXT ) { return new ConsoleResultsRenderer ; } throw new I... | Render the results |
52,561 | protected function parse ( $ data = null , $ filename = null ) { if ( json_last_error ( ) !== JSON_ERROR_NONE ) { $ error_message = 'Syntax error' ; if ( function_exists ( 'json_last_error_msg' ) ) { $ error_message = json_last_error_msg ( ) ; } $ error = [ 'message' => $ error_message , 'type' => json_last_error ( ) ,... | Completes parsing of JSON data |
52,562 | protected function parse ( $ data = null , $ filename = null ) { if ( $ data === false ) { $ errors = libxml_get_errors ( ) ; $ latestError = array_pop ( $ errors ) ; $ error = [ 'message' => $ latestError -> message , 'type' => $ latestError -> level , 'code' => $ latestError -> code , 'file' => $ filename , 'line' =>... | Completes parsing of XML data |
52,563 | protected function parse ( $ data = null , $ filename = null ) { if ( ! $ data ) { $ error = error_get_last ( ) ; if ( ! is_array ( $ error ) ) { $ error [ "message" ] = "No parsable content in data." ; } $ error [ "file" ] = $ filename ; if ( function_exists ( "error_clear_last" ) ) { error_clear_last ( ) ; } throw ne... | Completes parsing of INI data |
52,564 | public function merge ( ConfigInterface $ config ) { $ this -> data = array_replace_recursive ( $ this -> data , $ config -> all ( ) ) ; return $ this ; } | Merge config from another instance |
52,565 | protected function loadFromFile ( $ path , ParserInterface $ parser = null ) { $ paths = $ this -> getValidPath ( $ path ) ; $ this -> data = [ ] ; foreach ( $ paths as $ path ) { if ( $ parser === null ) { $ info = pathinfo ( $ path ) ; $ parts = explode ( '.' , $ info [ 'basename' ] ) ; $ extension = array_pop ( $ pa... | Loads configuration from file . |
52,566 | protected function loadFromString ( $ configuration , ParserInterface $ parser ) { $ this -> data = [ ] ; $ this -> data = array_replace_recursive ( $ this -> data , $ parser -> parseString ( $ configuration ) ) ; } | Loads configuration from string . |
52,567 | protected function getParser ( $ extension ) { foreach ( $ this -> supportedParsers as $ parser ) { if ( in_array ( $ extension , $ parser :: getSupportedExtensions ( ) ) ) { return new $ parser ( ) ; } } throw new UnsupportedFormatException ( 'Unsupported configuration format' ) ; } | Gets a parser for a given file extension . |
52,568 | protected function parse ( $ data = null , $ filename = null ) { if ( is_callable ( $ data ) ) { $ data = call_user_func ( $ data ) ; } if ( ! is_array ( $ data ) ) { throw new UnsupportedFormatException ( 'PHP data does not return an array' ) ; } return $ data ; } | Completes parsing of PHP data |
52,569 | public function pop ( $ queueName ) { $ cache = $ this -> get ( $ queueName ) ; if ( ! $ cache -> isEmpty ( ) ) { return $ cache -> dequeue ( ) ; } } | Get the next message in line . Or nothing if there is no more in the cache . |
52,570 | protected function get ( $ queueName ) { if ( isset ( $ this -> caches [ $ queueName ] ) ) { return $ this -> caches [ $ queueName ] ; } return $ this -> caches [ $ queueName ] = new \ SplQueue ( ) ; } | Create the queue cache internally if it doesn t yet exists . |
52,571 | public function createQueue ( $ queueName ) { $ channel = $ this -> getChannel ( ) ; $ channel -> exchange_declare ( $ this -> exchange , 'direct' , false , true , false ) ; $ channel -> queue_declare ( $ queueName , false , true , false , false ) ; $ channel -> queue_bind ( $ queueName , $ this -> exchange , $ queueNa... | Create a queue . |
52,572 | public function countMessages ( $ queueName ) { list ( , $ messageCount ) = $ this -> getChannel ( ) -> queue_declare ( $ queueName , true ) ; return $ messageCount ; } | Count the number of messages in queue . This can be a approximately number . |
52,573 | public function pushMessage ( $ queueName , $ message ) { $ amqpMessage = new AMQPMessage ( $ message , $ this -> defaultMessageParams ) ; $ this -> getChannel ( ) -> basic_publish ( $ amqpMessage , $ this -> exchange , $ queueName ) ; } | Insert a message at the top of the queue . |
52,574 | private function getJobFilename ( $ queueName ) { $ path = $ this -> baseDirectory . '/bernard.meta' ; if ( ! is_file ( $ path ) ) { touch ( $ path ) ; chmod ( $ path , $ this -> permissions ) ; } $ file = new \ SplFileObject ( $ path , 'r+' ) ; $ file -> flock ( LOCK_EX ) ; $ meta = unserialize ( $ file -> fgets ( ) )... | Generates a uuid . |
52,575 | public function peekQueue ( $ queueName , $ index = 0 , $ limit = 20 ) { if ( $ messages = $ this -> ironmq -> peekMessages ( $ queueName , $ limit ) ) { return $ this -> pluck ( $ messages , 'body' ) ; } return [ ] ; } | IronMQ does not support an offset when peeking messages . |
52,576 | private function doPopMessage ( $ queueName ) { $ query = 'SELECT id, message FROM bernard_messages WHERE queue = :queue AND visible = :visible ORDER BY sentAt LIMIT 1 ' . $ this -> connection -> getDatabasePlatform ( ) -> getForUpdateSql ( ) ; list ( $ id , $ message ) = $ this -> con... | Execute the actual query and process the response . |
52,577 | protected static function createQueueTable ( Schema $ schema ) { $ table = $ schema -> createTable ( 'bernard_queues' ) ; $ table -> addColumn ( 'name' , 'string' ) ; $ table -> setPrimaryKey ( [ 'name' ] ) ; } | Creates queue table on the current schema given . |
52,578 | protected static function createMessagesTable ( Schema $ schema ) { $ table = $ schema -> createTable ( 'bernard_messages' ) ; $ table -> addColumn ( 'id' , 'integer' , [ 'autoincrement' => true , 'unsigned' => true , 'notnull' => true , ] ) ; $ table -> addColumn ( 'queue' , 'string' ) ; $ table -> addColumn ( 'messag... | Creates message table on the current schema given . |
52,579 | public function tick ( Queue $ queue , array $ options = [ ] ) { $ this -> configure ( $ options ) ; if ( $ this -> shutdown ) { return false ; } if ( microtime ( true ) > $ this -> options [ 'max-runtime' ] ) { return false ; } if ( $ this -> pause ) { return true ; } $ this -> dispatcher -> dispatch ( BernardEvents :... | Returns true do indicate it should be run again or false to indicate it should not be run again . |
52,580 | public function invoke ( Envelope $ envelope , Queue $ queue ) { try { $ this -> dispatcher -> dispatch ( BernardEvents :: INVOKE , new EnvelopeEvent ( $ envelope , $ queue ) ) ; $ receiver = $ this -> router -> route ( $ envelope ) ; $ receiver -> receive ( $ envelope -> getMessage ( ) ) ; $ queue -> acknowledge ( $ e... | Until there is a real extension point to doing invoked stuff this can be used by wrapping the invoke method . |
52,581 | protected function bind ( ) { if ( function_exists ( 'pcntl_signal' ) ) { pcntl_signal ( SIGTERM , [ $ this , 'shutdown' ] ) ; pcntl_signal ( SIGINT , [ $ this , 'shutdown' ] ) ; pcntl_signal ( SIGQUIT , [ $ this , 'shutdown' ] ) ; pcntl_signal ( SIGUSR2 , [ $ this , 'pause' ] ) ; pcntl_signal ( SIGCONT , [ $ this , 'r... | Setup signal handlers for unix signals . |
52,582 | private function getCookiePath ( ) { $ path = dirname ( parse_url ( $ this -> getCurrentUrl ( ) , PHP_URL_PATH ) ) ; if ( '\\' === DIRECTORY_SEPARATOR ) { $ path = str_replace ( '\\' , '/' , $ path ) ; } return $ path ; } | Returns current cookie path . |
52,583 | protected function getFormField ( $ xpath ) { $ fieldNode = $ this -> getCrawlerNode ( $ this -> getFilteredCrawler ( $ xpath ) ) ; $ fieldName = str_replace ( '[]' , '' , $ fieldNode -> getAttribute ( 'name' ) ) ; $ formNode = $ this -> getFormNode ( $ fieldNode ) ; $ formId = $ this -> getFormNodeId ( $ formNode ) ; ... | Returns form field from XPath query . |
52,584 | private function getCheckboxField ( $ xpath ) { $ field = $ this -> getFormField ( $ xpath ) ; if ( ! $ field instanceof ChoiceFormField ) { throw new DriverException ( sprintf ( 'Impossible to check the element with XPath "%s" as it is not a checkbox' , $ xpath ) ) ; } return $ field ; } | Returns the checkbox field from xpath query ensuring it is valid . |
52,585 | private function getFieldPosition ( \ DOMElement $ fieldNode ) { $ elements = $ this -> getCrawler ( ) -> filterXPath ( '//*[@name=\'' . $ fieldNode -> getAttribute ( 'name' ) . '\']' ) ; if ( count ( $ elements ) > 1 ) { foreach ( $ elements as $ key => $ element ) { if ( $ element -> getNodePath ( ) === $ fieldNode -... | Gets the position of the field node among elements with the same name |
52,586 | private function canSubmitForm ( \ DOMElement $ node ) { $ type = $ node -> hasAttribute ( 'type' ) ? $ node -> getAttribute ( 'type' ) : null ; if ( 'input' === $ node -> nodeName && in_array ( $ type , array ( 'submit' , 'image' ) , true ) ) { return true ; } return 'button' === $ node -> nodeName && ( null === $ typ... | Determines if a node can submit a form . |
52,587 | private function canResetForm ( \ DOMElement $ node ) { $ type = $ node -> hasAttribute ( 'type' ) ? $ node -> getAttribute ( 'type' ) : null ; return in_array ( $ node -> nodeName , array ( 'input' , 'button' ) , true ) && 'reset' === $ type ; } | Determines if a node can reset a form . |
52,588 | private function getFormNodeId ( \ DOMElement $ form ) { return md5 ( $ form -> getLineNo ( ) . $ form -> getNodePath ( ) . $ form -> nodeValue ) ; } | Returns form node unique identifier . |
52,589 | private function getOptionValue ( \ DOMElement $ option ) { if ( $ option -> hasAttribute ( 'value' ) ) { return $ option -> getAttribute ( 'value' ) ; } if ( ! empty ( $ option -> nodeValue ) ) { return $ option -> nodeValue ; } return '1' ; } | Gets the value of an option element |
52,590 | private function mergeForms ( Form $ to , Form $ from ) { foreach ( $ from -> all ( ) as $ name => $ field ) { $ fieldReflection = new \ ReflectionObject ( $ field ) ; $ nodeReflection = $ fieldReflection -> getProperty ( 'node' ) ; $ valueReflection = $ fieldReflection -> getProperty ( 'value' ) ; $ nodeReflection -> ... | Merges second form values into first one . |
52,591 | private function getCrawlerNode ( Crawler $ crawler ) { $ node = null ; if ( $ crawler instanceof \ Iterator ) { $ crawler -> rewind ( ) ; $ node = $ crawler -> current ( ) ; } else { $ node = $ crawler -> getNode ( 0 ) ; } if ( null !== $ node ) { return $ node ; } throw new DriverException ( 'The element does not exi... | Returns DOMElement from crawler instance . |
52,592 | private function getFilteredCrawler ( $ xpath ) { if ( ! count ( $ crawler = $ this -> getCrawler ( ) -> filterXPath ( $ xpath ) ) ) { throw new DriverException ( sprintf ( 'There is no element matching XPath "%s"' , $ xpath ) ) ; } return $ crawler ; } | Returns a crawler filtered for the given XPath requiring at least 1 result . |
52,593 | public function doRequest ( $ request , $ location , $ action , $ version , $ one_way ) { return $ this -> __doRequest ( $ request , $ location , $ action , $ version , $ one_way ) ; } | Do soap request |
52,594 | public function SoapCall ( $ function , array $ params , array $ options = null , $ inputHeader = null , & $ outputHeaders = null ) { return $ this -> __soapCall ( $ function , $ params , $ options , $ inputHeader , $ outputHeaders ) ; } | Allias to do a soap call on the webservice client |
52,595 | public function add ( $ name , Closure $ closure ) { if ( ! $ this -> has ( $ name ) ) { $ service = new Service ( ) ; $ closure ( $ service ) ; $ this -> services [ $ name ] = $ service ; return $ this ; } throw new ServiceAlreadyExists ( "Service '" . $ name . "' already exists." ) ; } | Add a new service to the wrapper |
52,596 | public function addByArray ( array $ services = [ ] ) { if ( ! empty ( $ services ) ) { foreach ( $ services as $ name => $ methods ) { if ( ! $ this -> has ( $ name ) ) { $ service = new Service ( ) ; foreach ( $ methods as $ method => $ value ) { if ( method_exists ( $ service , $ method ) ) { $ service -> { $ method... | Add services by array |
52,597 | public function client ( $ name , Closure $ closure = null ) { if ( $ this -> has ( $ name ) ) { $ service = $ this -> services [ $ name ] ; if ( is_null ( $ service -> getClient ( ) ) ) { $ client = new Client ( $ service -> getWsdl ( ) , $ service -> getOptions ( ) , $ service -> getHeaders ( ) ) ; $ service -> clien... | Get the client |
52,598 | public function call ( $ call , $ data = [ ] , $ options = [ ] ) { list ( $ name , $ function ) = explode ( '.' , $ call , 2 ) ; return $ this -> client ( $ name , function ( $ client ) use ( $ function , $ data , $ options ) { return $ client -> SoapCall ( $ function , $ data , $ options ) ; } ) ; } | A easy access call method |
52,599 | public function getClassmap ( ) { $ classmap = $ this -> classmap ; $ classes = [ ] ; if ( ! empty ( $ classmap ) ) { foreach ( $ classmap as $ class ) { $ name = current ( array_slice ( explode ( '\\' , $ class ) , - 1 , 1 , true ) ) ; $ classes [ $ name ] = $ class ; } } return $ classes ; } | Get the classmap |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.