idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
42,000 | public function addItems ( array $ items , $ index = null ) { foreach ( $ items as $ item ) { $ currentIndex = array_search ( $ item , $ this -> items , true ) ; if ( $ currentIndex !== false ) { $ this -> removeItems ( [ $ item ] ) ; if ( $ currentIndex < $ index ) { $ index -- ; } } $ item -> setElementGroup ( $ this... | Add items . |
42,001 | public function removeItems ( $ items ) { foreach ( $ items as $ item ) { $ index = array_search ( $ item , $ this -> items , true ) ; if ( $ index !== false ) { $ item -> setElementGroup ( null ) ; array_splice ( $ this -> items , $ index , 1 ) ; } } $ this -> group -> clearContent ( ) ; $ this -> group -> appendConte... | Remove items . |
42,002 | public function clearItems ( ) { foreach ( $ this -> items as $ item ) { $ item -> setElementGroup ( null ) ; } $ this -> items = [ ] ; $ this -> group -> clearContent ( ) ; return $ this ; } | Clear all items . |
42,003 | public function setIndicator ( $ indicator = null ) { if ( $ this -> indicatorName !== null ) { $ this -> indicator -> removeClasses ( [ 'oo-ui-indicator-' . $ this -> indicatorName ] ) ; } if ( $ indicator !== null ) { $ this -> indicator -> addClasses ( [ 'oo-ui-indicator-' . $ indicator ] ) ; } $ this -> indicatorNa... | Set indicator name . |
42,004 | public function setLabel ( $ label ) { $ this -> labelValue = ( string ) $ label !== '' ? $ label : null ; $ this -> label -> clearContent ( ) ; if ( $ this -> labelValue !== null ) { if ( is_string ( $ this -> labelValue ) && trim ( $ this -> labelValue ) === '' ) { $ this -> label -> appendContent ( new HtmlSnippet (... | Set the label . |
42,005 | public function supports ( $ methods ) { $ support = 0 ; $ methods = ( array ) $ methods ; foreach ( $ methods as $ method ) { if ( method_exists ( $ this , $ method ) ) { $ support ++ ; continue ; } } return count ( $ methods ) === $ support ; } | Check if element supports one or more methods . |
42,006 | private function getSerializedConfig ( ) { $ config = [ '_' => true ] ; $ config = $ this -> getConfig ( $ config ) ; $ replaceElements = function ( & $ item ) { if ( $ item instanceof Tag ) { $ item -> ensureInfusableId ( ) ; $ item = [ 'tag' => $ item -> getAttribute ( 'id' ) ] ; } elseif ( $ item instanceof HtmlSnip... | Create a modified version of the configuration array suitable for JSON serialization by replacing Tag references and HtmlSnippet s . |
42,007 | public static function configFromHtmlAttributes ( array $ attrs ) { $ booleanAttrs = [ 'disabled' => true , 'required' => true , 'autofocus' => true , 'multiple' => true , 'readonly' => true , ] ; $ attributeToConfig = [ 'maxlength' => 'maxLength' , 'readonly' => 'readOnly' , 'tabindex' => 'tabIndex' , 'accesskey' => '... | A helper method to massage an array of HTML attributes into a format that is more likely to work with an OOUI PHP element camel - casing attribute names and setting values of boolean ones to true . Intended as a convenience to be used when refactoring legacy systems using HTML to use OOUI . |
42,008 | protected function setAlignment ( $ value ) { if ( $ value !== $ this -> align ) { if ( ! in_array ( $ value , [ 'left' , 'right' , 'top' , 'inline' ] ) ) { $ value = 'left' ; } if ( $ value === 'inline' && ! $ this -> isFieldInline ( ) ) { $ value = 'top' ; } $ this -> body -> clearContent ( ) ; if ( $ this -> helpInl... | Set the field alignment mode . |
42,009 | private function createHelpElement ( ) { if ( $ this -> helpInline ) { return new LabelWidget ( [ 'classes' => [ 'oo-ui-inline-help' ] , 'label' => $ this -> helpText , ] ) ; } else { return new ButtonWidget ( [ 'classes' => [ 'oo-ui-fieldLayout-help' ] , 'framed' => false , 'icon' => 'info' , 'title' => $ this -> help... | Creates and returns the help element . |
42,010 | public function setSelected ( $ state ) { if ( $ state ) { $ this -> input -> setAttributes ( [ 'checked' => 'checked' ] ) ; } else { $ this -> input -> removeAttributes ( [ 'checked' ] ) ; } return $ this ; } | Set selection state of this radio button . |
42,011 | public function toggleFramed ( $ framed = null ) { $ this -> framed = $ framed !== null ? ( bool ) $ framed : ! $ this -> framed ; $ this -> toggleClasses ( [ 'oo-ui-buttonElement-framed' ] , $ this -> framed ) ; $ this -> toggleClasses ( [ 'oo-ui-buttonElement-frameless' ] , ! $ this -> framed ) ; return $ this ; } | Toggle frame . |
42,012 | public function setAccessKey ( $ accessKey ) { $ accessKey = is_string ( $ accessKey ) && strlen ( $ accessKey ) ? $ accessKey : null ; if ( $ this -> accessKey !== $ accessKey ) { if ( $ accessKey !== null ) { $ this -> accessKeyed -> setAttributes ( [ 'accesskey' => $ accessKey ] ) ; } else { $ this -> accessKeyed ->... | Set access key . |
42,013 | public function addClasses ( array $ classes ) { $ this -> classes = array_unique ( array_merge ( $ this -> classes , $ classes ) ) ; return $ this ; } | Add CSS classes . |
42,014 | public function toggleClasses ( array $ classes , $ toggle = null ) { if ( $ toggle === null ) { $ this -> classes = array_diff ( array_merge ( $ this -> classes , $ classes ) , array_intersect ( $ this -> classes , $ classes ) ) ; } elseif ( $ toggle ) { $ this -> classes = array_merge ( $ this -> classes , $ classes ... | Toggle CSS classes . |
42,015 | public function removeContent ( ... $ content ) { if ( is_array ( $ content [ 0 ] ) ) { $ content = $ content [ 0 ] ; } foreach ( $ content as $ item ) { if ( ! is_string ( $ item ) ) { $ index = array_search ( $ item , $ this -> content , true ) ; if ( $ index !== false ) { array_splice ( $ this -> content , $ index ,... | Remove any items that match by reference |
42,016 | public function appendContent ( ... $ content ) { if ( is_array ( $ content [ 0 ] ) ) { $ content = $ content [ 0 ] ; } $ this -> removeContent ( $ content ) ; $ this -> content = array_merge ( $ this -> content , $ content ) ; return $ this ; } | Add content to the end . |
42,017 | public function prependContent ( ... $ content ) { if ( is_array ( $ content [ 0 ] ) ) { $ content = $ content [ 0 ] ; } $ this -> removeContent ( $ content ) ; array_splice ( $ this -> content , 0 , 0 , $ content ) ; return $ this ; } | Add content to the beginning . |
42,018 | public function ensureInfusableId ( ) { $ this -> setInfusable ( true ) ; if ( $ this -> getAttribute ( 'id' ) === null ) { $ this -> setAttributes ( [ 'id' => self :: generateElementId ( ) ] ) ; } return $ this ; } | Ensure that this given Tag is infusable and has a unique id attribute . |
42,019 | public function clearFlags ( ) { $ remove = [ ] ; $ classPrefix = 'oo-ui-flaggedElement-' ; foreach ( $ this -> flags as $ flag ) { $ remove [ ] = $ classPrefix . $ flag ; } $ this -> flagged -> removeClasses ( $ remove ) ; $ this -> flags = [ ] ; return $ this ; } | Clear all flags . |
42,020 | public function setFlags ( $ flags ) { $ add = [ ] ; $ remove = [ ] ; $ classPrefix = 'oo-ui-flaggedElement-' ; if ( is_string ( $ flags ) ) { if ( ! isset ( $ this -> flags [ $ flags ] ) ) { $ this -> flags [ $ flags ] = true ; $ add [ ] = $ classPrefix . $ flags ; } } elseif ( is_array ( $ flags ) ) { foreach ( $ fla... | Add one or more flags . |
42,021 | private function fetchJobs ( PheanstalkInterface $ pheanstalk , $ tubeName ) { try { $ nextJobReady = $ pheanstalk -> peekReady ( $ tubeName ) ; $ this -> data [ 'jobs' ] [ $ tubeName ] [ 'ready' ] = [ 'id' => $ nextJobReady -> getId ( ) , 'data' => $ nextJobReady -> getData ( ) , ] ; } catch ( ServerException $ e ) { ... | Get the next job ready and buried in the specified tube and connection . |
42,022 | public function configureConnections ( ContainerBuilder $ container , array $ config ) { $ connectionLocatorDef = new Definition ( PheanstalkLocator :: class ) ; $ container -> setDefinition ( 'leezy.pheanstalk.pheanstalk_locator' , $ connectionLocatorDef ) ; $ container -> setParameter ( 'leezy.pheanstalk.pheanstalks'... | Configures the Connections and Connection Locator . |
42,023 | public function configureProfiler ( ContainerBuilder $ container , array $ config ) { $ dataCollectorDef = new Definition ( PheanstalkDataCollector :: class ) ; $ dataCollectorDef -> setPublic ( false ) ; $ dataCollectorDef -> addTag ( 'data_collector' , [ 'id' => 'pheanstalk' , 'template' => $ config [ 'profiler' ] [ ... | Configures the profiler data collector . |
42,024 | private function cleanup ( ) : void { CharacterBlueprint :: where ( 'character_id' , $ this -> getCharacterId ( ) ) -> whereNotIn ( 'item_id' , $ this -> cleanup_ids -> flatten ( ) -> unique ( ) -> all ( ) ) -> delete ( ) ; } | Removes older entries from blueprints table . |
42,025 | private function getCharacterAssetLocations ( ) : array { $ assets = CharacterAsset :: where ( 'character_id' , $ this -> getCharacterId ( ) ) -> where ( 'location_flag' , 'Hangar' ) -> where ( 'location_type' , 'other' ) -> where ( 'location_id' , '<>' , self :: ASSET_SAFETY ) -> whereNotBetween ( 'location_id' , self... | Gets the current characters asset locations . |
42,026 | public function validateCall ( ) : void { if ( ! in_array ( $ this -> method , [ 'get' , 'post' , 'put' , 'patch' , 'delete' ] ) ) throw new Exception ( 'Invalid HTTP method used' ) ; if ( trim ( $ this -> endpoint ) === '' ) throw new Exception ( 'Empty endpoint used' ) ; if ( trim ( $ this -> version ) === '' && ! ( ... | Validates a call to ensure that a method and endpoint is set in the job that is using this base class . |
42,027 | public function tags ( ) : array { if ( property_exists ( $ this , 'tags' ) ) { if ( is_null ( $ this -> token ) ) return array_merge ( $ this -> tags , [ 'public' ] ) ; return array_merge ( $ this -> tags , [ 'character_id:' . $ this -> getCharacterId ( ) ] ) ; } if ( is_null ( $ this -> token ) ) return [ 'unknown_ta... | Assign this job a tag so that Horizon can categorize and allow for specific tags to be monitored . |
42,028 | public function eseye ( ) { if ( $ this -> client ) return $ this -> client ; $ this -> client = app ( 'esi-client' ) ; if ( is_null ( $ this -> token ) ) return $ this -> client = $ this -> client -> get ( ) ; return $ this -> client = $ this -> client -> get ( new EsiAuthentication ( [ 'refresh_token' => $ this -> to... | Get an instance of Eseye to use for this job . |
42,029 | public function logWarnings ( EsiResponse $ response ) : void { if ( ! is_null ( $ response -> pages ) && $ this -> page === null ) { $ this -> eseye ( ) -> getLogger ( ) -> warning ( 'Response contained pages but none was expected' ) ; dispatch ( ( new Analytics ( ( new AnalyticsContainer ) -> set ( 'type' , 'endpoint... | Logs warnings to the Eseye logger . |
42,030 | public function updateRefreshToken ( ) : void { tap ( $ this -> token , function ( $ token ) { if ( is_null ( $ this -> client ) || $ this -> public_call ) return ; $ last_auth = $ this -> client -> getAuthentication ( ) ; $ token -> token = $ last_auth -> access_token ?? '-' ; $ token -> expires_on = $ last_auth -> to... | Update the access_token last used in the job along with the expiry time . |
42,031 | public function nextPage ( int $ pages ) : bool { if ( $ this -> page >= $ pages ) return false ; $ this -> page ++ ; return true ; } | Check if there are any pages left in a response based on the number of pages available and the current page . |
42,032 | public function failed ( Exception $ exception ) { $ this -> incrementEsiRateLimit ( ) ; dispatch ( ( new Analytics ( ( new AnalyticsContainer ) -> set ( 'type' , 'exception' ) -> set ( 'exd' , get_class ( $ exception ) . ':' . $ exception -> getMessage ( ) ) -> set ( 'exf' , 1 ) ) ) ) ; throw $ exception ; } | When a job fails grab some information and send a GA event about the exception . The Analytics job does the work of checking if analytics is disabled or not so we don t have to care about that here . |
42,033 | public function get ( EsiAuthentication $ authentication = null ) : Eseye { if ( $ authentication ) { tap ( $ authentication , function ( $ auth ) { $ auth -> client_id = env ( 'EVE_CLIENT_ID' ) ; $ auth -> secret = env ( 'EVE_CLIENT_SECRET' ) ; } ) ; return new Eseye ( $ authentication ) ; } return new Eseye ; } | Gets an instance of Eseye . |
42,034 | public function isRateLimited ( ) : bool { if ( cache ( ) -> get ( $ this -> getRateLimitKey ( ) ) < $ this -> getRateLimit ( ) ) return false ; return true ; } | Checks if the current cache key is to be considered rate limited . |
42,035 | public function incrementRateLimitCallCount ( int $ amount = 1 ) { cache ( ) -> set ( $ this -> getRateLimitKey ( ) , $ amount , carbon ( 'now' ) -> addMinute ( 1 ) ) ; } | Increments the number of calls that have been made . |
42,036 | private function resetCollections ( ) { $ this -> planet_pins = collect ( ) ; $ this -> planet_factories = collect ( ) ; $ this -> planet_extractors = collect ( ) ; $ this -> planet_heads = collect ( ) ; $ this -> planet_links = collect ( ) ; $ this -> planet_waypoints = collect ( ) ; $ this -> planet_routes = collect ... | Resets the collections used for cleanup routines . |
42,037 | private function planetCleanup ( $ planet ) { $ this -> cleanRouteWaypoints ( $ planet ) ; $ this -> cleanRoutes ( $ planet ) ; $ this -> cleanLinks ( $ planet ) ; $ this -> cleanContents ( $ planet ) ; $ this -> cleanHeads ( $ planet ) ; $ this -> cleanExtractors ( $ planet ) ; $ this -> cleanFactories ( $ planet ) ; ... | Performs a cleanup of any routes links or contents of a planet . |
42,038 | public function preflighted ( ) : bool { if ( $ this -> isEsiDown ( ) ) return false ; if ( in_array ( 'corporation' , $ this -> tags ( ) ) && $ this -> isNPCCorporation ( ) ) return false ; if ( $ this -> isPublicEndpoint ( ) ) return true ; if ( count ( $ this -> roles ) > 0 ) { if ( $ this -> isNPCCorporation ( ) ) ... | Perform a number of preflight checks for an API call . |
42,039 | public function isEsiDown ( ) : bool { if ( $ this -> isEsiRateLimited ( ) ) return true ; $ status = Cache :: remember ( 'esi_db_status' , 1 , function ( ) { return EsiStatus :: latest ( ) -> first ( ) ; } ) ; if ( ! $ status ) return false ; if ( $ status -> created_at -> lte ( carbon ( 'now' ) -> subHours ( 2 ) ) ) ... | Determine if ESI could be down . |
42,040 | public function isPublicEndpoint ( ) : bool { if ( $ this -> public_call || is_null ( $ this -> token ) || $ this -> scope === 'public' ) return true ; return false ; } | Check for a public enpoint call . |
42,041 | public function isCorpCharacterWithRoles ( ) : bool { array_push ( $ this -> roles , 'Director' ) ; if ( in_array ( $ this -> scope , $ this -> token -> scopes ) && ! empty ( array_intersect ( $ this -> roles , $ this -> getCharacterRoles ( ) ) ) ) { return true ; } return false ; } | Determine if the current character refresh token has the roles needed to make the corporation API call . |
42,042 | public function getNameAttribute ( $ value ) { if ( ! $ this -> type ) return null ; if ( is_null ( $ value ) || $ value == '' ) return $ this -> type -> typeName ; return $ value ; } | Allow us to call CharacterAsset - > name . |
42,043 | public function getUsedVolumeAttribute ( ) { $ content = $ this -> content ; if ( ! is_null ( $ content ) ) return $ content -> sum ( function ( $ item ) { return $ item -> type -> volume ; } ) ; return 0.0 ; } | Provide the used space based on stored item volume . |
42,044 | public function readString ( $ ini ) { $ ini .= "\n" ; if ( $ this -> useNativeFunction ) { $ array = $ this -> readWithNativeFunction ( $ ini ) ; } else { $ array = $ this -> readWithAlternativeImplementation ( $ ini ) ; } return $ array ; } | Reads a INI configuration string and returns it as an array . |
42,045 | public function readComments ( $ filename ) { $ ini = $ this -> getContentOfIniFile ( $ filename ) ; $ ini = $ this -> splitIniContentIntoLines ( $ ini ) ; $ descriptions = array ( ) ; $ section = '' ; $ lastComment = '' ; foreach ( $ ini as $ line ) { $ line = trim ( $ line ) ; if ( strpos ( $ line , '[' ) === 0 ) { $... | Reads ini comments for each key . |
42,046 | public function writeToString ( array $ config , $ header = '' ) { $ ini = $ header ; $ sectionNames = array_keys ( $ config ) ; foreach ( $ sectionNames as $ sectionName ) { $ section = $ config [ $ sectionName ] ; if ( empty ( $ section ) ) { continue ; } if ( ! is_array ( $ section ) ) { throw new IniWritingExceptio... | Writes an array configuration to a INI string and returns it . |
42,047 | public function handle ( ) : void { try { $ this -> driver -> wait ( function ( MessageInterface $ message ) { $ this -> log ( LogLevel :: INFO , "Start handle message #{$message->getId()} ({$message->getType()})" , $ this -> messageLoggerContext ( $ message ) ) ; $ result = $ this -> dispatch ( $ message ) ; if ( $ th... | Basic method for background job to star listening . |
42,048 | private function handleMessage ( HandlerInterface $ handler , MessageInterface $ message ) : bool { if ( $ this -> logger && method_exists ( $ handler , 'setLogger' ) ) { $ handler -> setLogger ( $ this -> logger ) ; } try { $ result = $ handler -> handle ( $ message ) ; $ this -> log ( LogLevel :: INFO , "End handle m... | Handle given message with given handler |
42,049 | private function hasHandlers ( string $ type ) : bool { return isset ( $ this -> handlers [ $ type ] ) && count ( $ this -> handlers [ $ type ] ) > 0 ; } | Check if actual dispatcher has handler for given type |
42,050 | private function messageLoggerContext ( MessageInterface $ message ) : array { return [ 'id' => $ message -> getId ( ) , 'created' => $ message -> getCreated ( ) , 'type' => $ message -> getType ( ) , 'payload' => $ message -> getPayload ( ) , ] ; } | Serialize message to logger context |
42,051 | private function performRequest ( $ command , $ parameters ) { $ parameters [ "key" ] = $ this -> api_key ; $ param_array = array ( ) ; foreach ( $ parameters as $ key => $ value ) $ param_array [ ] = "$key=" . urlencode ( $ value ) ; $ params = implode ( "&" , $ param_array ) ; $ url = $ this -> base_url . $ command .... | Prepare the call to the API server |
42,052 | private function call ( $ url ) { $ handle = curl_init ( ) ; curl_setopt ( $ handle , CURLOPT_URL , $ url ) ; curl_setopt ( $ handle , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ handle , CURLOPT_ENCODING , "" ) ; curl_setopt ( $ handle , CURLOPT_MAXREDIRS , 10 ) ; curl_setopt ( $ handle , CURLOPT_TIMEOUT , 30 ) ... | Make the call to the API server |
42,053 | public function cc ( string $ email , string $ name = null ) { $ this -> mailer -> addCC ( $ email , $ name ?? '' ) ; return $ this ; } | Send mail carbon copy |
42,054 | public function bcc ( string $ email , string $ name = null ) { $ this -> mailer -> addBCC ( $ email , $ name ?? '' ) ; return $ this ; } | Send mail blind carbon copy |
42,055 | protected function getFullPath ( $ item = null ) { if ( ! $ item ) { $ item = $ this ; } if ( ! $ parent = $ item -> parent ) { return str_start ( $ item -> slug , '/' ) ; } return str_start ( sprintf ( '%s%s' , $ this -> getFullPath ( $ parent ) , str_start ( $ item -> slug , '/' ) ) , '/' ) ; } | Get full path . |
42,056 | public function getFullPathAttribute ( ) { $ pathSections = explode ( '/' , $ this -> getFullPath ( ) ) ; $ slugsToExclude = array_wrap ( $ this -> domainMappedFolders ) ; $ finalSlug = collect ( $ pathSections ) -> filter ( ) -> reject ( function ( $ slug ) use ( $ slugsToExclude ) { return in_array ( $ slug , $ slugs... | Add full path attribute . |
42,057 | public function scopeWhereFullPath ( Builder $ query , string $ path ) { $ itemSlugs = explode ( '/' , $ path ) ; return $ query -> where ( 'slug' , '=' , end ( $ itemSlugs ) ) -> get ( ) -> filter ( function ( $ item ) use ( $ path ) { return $ item -> full_path === str_start ( $ path , '/' ) ; } ) ; } | Scope the query to only items that match the full path . |
42,058 | protected function getLinkHtml ( $ text , $ page , $ css ) { $ html = $ this -> buttonHtmlPattern ; $ html = str_replace ( '{href}' , $ this -> getLinkHref ( $ page ) , $ html ) ; $ html = str_replace ( '{text}' , $ text , $ html ) ; $ html = str_replace ( '{page}' , $ page , $ html ) ; $ html = str_replace ( '{class}'... | Get the HTML for complete link |
42,059 | protected function detectOtherValues ( ) { $ this -> totalPages = ceil ( $ this -> maxItems / $ this -> itemsPerPage ) ; $ this -> half = floor ( $ this -> numberOfPageLinks / 2 ) ; $ this -> startPage = $ this -> currentPage - $ this -> half ; if ( $ this -> startPage < 1 ) { $ this -> startPage = 1 ; } $ this -> endP... | Detect other values needed for generate methods |
42,060 | public function toHtml ( ) { $ this -> detectOtherValues ( ) ; $ html = '' ; $ html .= "<{$this->mainPaginationTag} class=\"{$this->mainCssClass}\">" ; $ html .= $ this -> getHtml4FirstPage ( ) ; $ html .= $ this -> getHtml4PreviousPage ( ) ; $ html .= $ this -> getHtml4Pages ( ) ; $ html .= $ this -> getHtml4NextPage ... | The generate method |
42,061 | public function getData ( bool $ trimStrings = null ) : array { $ trimStrings = ( $ trimStrings === null ) ? true : $ trimStrings ; $ data = $ this -> data ; foreach ( $ data as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> rules ) ) { if ( $ value === '' ) { $ data [ $ key ] = null ; } } if ( $ trimSt... | Get the data we re going to validate |
42,062 | protected function validatePresent ( $ value , string $ parameter , array $ args = [ ] , ? array $ rules , array $ context ) : ? string { if ( ! array_key_exists ( $ parameter , $ context ) ) { return Message :: getMessage ( Message :: PRESENT , [ 'param' => $ parameter ] ) ; } return null ; } | Validate if parameter is present in array data . It will fail if parameter name does not exists within data being validated . |
42,063 | protected function validateMin ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'min\' has to have defined minimum value' ) ; } $ minSize = $ args [ 0 ] ?? null ; if ( ! is_n... | Validate if value has the minimum value of |
42,064 | protected function validateMax ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'max\' has to have defined maximum value' ) ; } $ maxSize = $ args [ 0 ] ?? null ; if ( ! is_n... | Validate if value has the maximum value of |
42,065 | protected function validateMinLength ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'minLength\' has to have defined minimum value' ) ; } if ( ! is_numeric ( $ args [ 0 ] )... | Validate minimum length of value . If value is numeric it ll be converted to string |
42,066 | protected function validateMaxLength ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'maxLength\' has to have defined maximum value' ) ; } if ( ! is_numeric ( $ args [ 0 ] )... | Validate maximum length of value . If value is numeric it ll be converted to string |
42,067 | protected function validateLength ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'length\' has to have defined maximum value' ) ; } if ( ! is_numeric ( $ args [ 0 ] ) ) { t... | Validate the exact length of string |
42,068 | protected function validateInteger ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value ... | Validate if given value is integer . If you need to validate min and max then chain those validators |
42,069 | protected function validateAlphaNum ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value... | Validate if given value is alpha numeric or not allowing lower and uppercase English letters with numbers |
42,070 | protected function validateHex ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = tr... | Validate if given value is hexadecimal number or not |
42,071 | protected function validateAlpha ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = ... | Validate if given value contains alpha chars only or not allowing lower and uppercase English letters |
42,072 | protected function validateEmail ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = ... | Validate if given value is valid email address by syntax |
42,073 | protected function validateSlug ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = t... | Validate if given value is valid URL slug |
42,074 | protected function validateDecimal ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( "Validator 'decimal' must have argument in validator list for parameter {$parameter}" ) ; } $ decimals... | Validate if given value has equal or less number of required decimals |
42,075 | protected function validateSame ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( "Validator 'same' must have argument in validator list for parameter {$parameter}" ) ; } $ sameAsField = ... | Validate if value is the same as value in other field |
42,076 | protected function validateDifferent ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( "Validator 'different' must have argument in validator list for parameter {$parameter}" ) ; } $ diff... | Opposite of same passes if value is different then value in other field |
42,077 | protected function validateDate ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { $ format = $ args [ 0 ] ?? null ; if ( $ format === '' ) { throw new ValidatorConfigException ( "Invalid format specified in 'date' validator for parameter {$parameter}" ) ;... | Validate if given value is properly formatted date |
42,078 | protected function validateAnyOf ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( "Validator 'anyOf' must have at least one defined value; parameter={$parameter}" ) ; } if ( $ args [ 0 ]... | Validate if value is any of allowed values |
42,079 | protected function validateUnique ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) < 2 ) { throw new ValidatorConfigException ( "Validator 'unique' must have at least two defined arguments; parameter={$parameter}" ) ; } array_walk (... | Return error if value is not unique in database |
42,080 | protected function validateExists ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) < 2 ) { throw new ValidatorConfigException ( "Validator 'exists' must have at least two defined arguments; parameter={$parameter}" ) ; } array_walk (... | Return error if value does not exists in database |
42,081 | protected function validateCsrf ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = t... | Validate if given value has valid CSRF token |
42,082 | protected function validateArray ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { $ count = $ args [ 0 ] ?? null ; if ( $ count !== null ) { if ( $ count == '' || ! is_numeric ( $ count ) ) { throw new ValidatorConfigException ( "Invalid array count defi... | Validate if given value is PHP array |
42,083 | public function getHeaders ( ) : array { if ( $ this -> headers === null && $ this -> headersText !== null ) { $ this -> headers = [ ] ; foreach ( explode ( "\n" , $ this -> headersText ) as $ line ) { $ pos = strpos ( $ line , ':' ) ; if ( $ pos === false ) { $ this -> headers [ $ line ] = null ; } else { $ name = sub... | Get all response headers as array where key is the header name and value is header value |
42,084 | public static function init ( ) : void { if ( static :: $ adapters === null ) { static :: $ randomNumber = rand ( 100000 , 999999 ) ; static :: resetWho ( ) ; static :: $ adapters = [ ] ; $ configs = Application :: getConfig ( 'application' ) -> get ( 'log' , [ ] ) ; $ count = 0 ; foreach ( $ configs as $ index => $ co... | Initialize load config and etc . |
42,085 | public static function resetWho ( ) : void { if ( Application :: isCli ( ) ) { static :: $ who = Application :: getCliName ( ) . '-' . static :: $ randomNumber ; } else { static :: $ who = Request :: ip ( ) . '-' . static :: $ randomNumber ; } } | Reset the who value |
42,086 | public static function temporaryDisable ( $ levels = null ) : void { $ disable = true ; if ( is_array ( $ levels ) ) { $ disable = $ levels ; } else if ( is_string ( $ levels ) ) { $ disable = [ $ levels ] ; } static :: $ temporaryDisabled = $ disable ; } | Temporary disable all logging |
42,087 | public static function emergency ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'emergency' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: EMERGENCY ) ) { $ adapter -> emergency ( ( new Message ( self :: EMERGENCY ) ) -> setMessa... | Write EMERGENCY message to log |
42,088 | public static function alert ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'alert' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: ALERT ) ) { $ adapter -> alert ( ( new Message ( self :: ALERT ) ) -> setMessages ( $ messages ) )... | Write ALERT message to log |
42,089 | public static function critical ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'critical' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: CRITICAL ) ) { $ adapter -> critical ( ( new Message ( self :: CRITICAL ) ) -> setMessages (... | Write CRITICAL message to log |
42,090 | public static function debug ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'debug' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: DEBUG ) ) { $ adapter -> debug ( ( new Message ( self :: DEBUG ) ) -> setMessages ( $ messages ) )... | Write DEBUG message to log |
42,091 | public static function notice ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'notice' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: NOTICE ) ) { $ adapter -> notice ( ( new Message ( self :: NOTICE ) ) -> setMessages ( $ message... | Write NOTICE message to log |
42,092 | public static function info ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'info' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: INFO ) ) { $ adapter -> info ( ( new Message ( self :: INFO ) ) -> setMessages ( $ messages ) ) ; } ... | Write INFO message to log |
42,093 | public static function warning ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'warning' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: WARNING ) ) { $ adapter -> warning ( ( new Message ( self :: WARNING ) ) -> setMessages ( $ me... | Write WARNING message to log |
42,094 | public static function error ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'error' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: ERROR ) ) { $ adapter -> error ( ( new Message ( self :: ERROR ) ) -> setMessages ( $ messages ) )... | Write ERROR message to log |
42,095 | public static function sql ( ... $ messages ) : void { static :: init ( ) ; if ( ! static :: isTemporaryDisabled ( 'sql' ) ) { foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( self :: SQL ) ) { $ adapter -> sql ( ( new Message ( self :: SQL ) ) -> setMessages ( $ messages ) ) ; } } } } | Write SQL query to log |
42,096 | public static function message ( Message $ message ) : void { static :: init ( ) ; foreach ( static :: $ adapters as $ adapter ) { if ( $ adapter -> isLevelEnabled ( $ message -> getLevel ( ) ) ) { $ adapter -> logMessage ( $ message ) ; } } } | Log message with prepared Log \ Message instance |
42,097 | public static function str2hex ( string $ x ) : string { $ string = '' ; foreach ( str_split ( $ x ) as $ char ) { $ string .= sprintf ( '%02X' , ord ( $ char ) ) ; } return $ string ; } | Get the hex representation of string |
42,098 | public static function truncate ( string $ string , int $ length = 80 , string $ etc = '...' , bool $ breakWords = false , bool $ middle = false ) : string { if ( $ length == 0 ) { return '' ; } $ encoding = Application :: getEncoding ( ) ; if ( mb_strlen ( $ string , $ encoding ) > $ length ) { $ length -= min ( $ len... | Truncate the long string properly |
42,099 | public static function a ( string $ text , string $ target = null ) : string { return preg_replace ( '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@' , "<a href=\"\$1\"" . ( $ target != null ? " target=\"{$target}\"" : '' ) . ">$1</a>" , $ text ) ; } | Detect URLs in text and replace them with HTML A tag |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.