idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
8,200
public function install ( ) { $ build = $ this ( 'mysql' , $ this -> databases [ 'default' ] [ 'host' ] , '' , $ this -> databases [ 'default' ] [ 'user' ] , $ this -> databases [ 'default' ] [ 'pass' ] ) ; $ main = $ this ( 'mysql' , $ this -> databases [ 'default' ] [ 'host' ] , $ this -> databases [ 'default' ] [ 'n...
Installs the database
8,201
public function find ( $ uuid , $ max_version = null ) : ? Snapshot { $ criteria = new Criteria ( ) ; $ criteria -> where ( Criteria :: expr ( ) -> eq ( 'uuid' , $ uuid ) ) ; if ( null !== $ max_version ) { $ criteria -> andWhere ( Criteria :: expr ( ) -> lte ( 'version' , $ max_version ) ) ; } $ criteria -> orderBy ( ...
Finds the latest Snapshot of an Aggregate .
8,202
public function save ( AggregateInterface $ aggregate ) : void { $ snapshot = new Snapshot ( ) ; $ snapshot -> setUuid ( $ aggregate -> getUuid ( ) ) ; $ snapshot -> setVersion ( $ aggregate -> getVersion ( ) ) ; $ snapshot -> setAggregateCreated ( $ aggregate -> getCreated ( ) ) ; $ snapshot -> setAggregateModified ( ...
Saves a Snapshot .
8,203
public function build ( $ timestamp = null ) { if ( null === $ timestamp ) { $ timestamp = new \ DateTime ( ) ; $ timestamp = $ timestamp -> format ( 'YmdHis' ) ; } $ fileName = sprintf ( '%s_%s.php' , $ timestamp , S :: underscored ( $ this -> migrationName ) ) ; return $ fileName ; }
Build migration file name .
8,204
public function get ( string $ date = null ) : array { if ( $ date === null ) { $ date = \ date ( 'Y-m-d' ) ; } return [ 'queued' => $ this -> queue -> count ( ) , 'pass' => $ this -> queue -> getStatsByType ( $ date , 'pass' ) , 'fail' => $ this -> queue -> getStatsByType ( $ date , 'fail' ) , 'retry' => $ this -> que...
Retrieves stats for a given date
8,205
private function getDataOnlyEntity ( ) : array { $ data = [ ] ; foreach ( $ this -> dicionario as $ meta ) { if ( ! in_array ( $ meta -> getFormat ( ) , [ "extend_mult" , "list_mult" , "selecao_mult" , "information" , "checkbox_mult" ] ) && ( $ meta -> getFormat ( ) !== "password" || strlen ( $ meta -> getValue ( ) ) >...
Retorna valores de uma entidade correspondente ao seu armazenamento em sql na sua tabela
8,206
public function dropColumn ( $ name ) { $ column = new TextColumn ( $ name ) ; $ column -> setTable ( $ this ) ; $ this -> actions [ ] = function ( ) use ( $ column ) { return $ this -> manipulation -> drop ( $ column ) ; } ; return $ this ; }
Drop a column .
8,207
public function addForeignKey ( $ referenceTable , $ referenceColumns , array $ options = [ ] ) { $ schema = isset ( $ options [ 'schema' ] ) ? new Schema ( $ options [ 'schema' ] ) : null ; $ foreignKey = new ForeignKey ( $ this , new Table ( $ referenceTable , $ schema ) ) ; $ foreignKey -> setReferencedColumns ( $ r...
Add a foreign key .
8,208
public function dropForeignKey ( $ referenceTable , $ referenceColumns , array $ options = [ ] ) { $ schema = isset ( $ options [ 'schema' ] ) ? new Schema ( $ options [ 'schema' ] ) : null ; $ foreignKey = new ForeignKey ( $ this , new Table ( $ referenceTable , $ schema ) ) ; $ foreignKey -> setColumns ( $ referenceC...
Drop a foreign key .
8,209
public function addUnique ( $ columns ) { $ unique = new Unique ( $ columns , $ this ) ; $ this -> actions [ ] = function ( ) use ( $ unique ) { return $ this -> manipulation -> create ( $ unique ) ; } ; return $ this ; }
Add a unique constraint .
8,210
public function dropUnique ( $ columns ) { $ unique = new Unique ( $ columns , $ this ) ; $ this -> actions [ ] = function ( ) use ( $ unique ) { return $ this -> manipulation -> drop ( $ unique ) ; } ; return $ this ; }
Drop a unique constraint .
8,211
public function addIndex ( $ columns ) { $ index = new Index ( $ columns , $ this ) ; $ this -> actions [ ] = function ( ) use ( $ index ) { return $ this -> manipulation -> create ( $ index ) ; } ; return $ this ; }
Add a index on columns .
8,212
public function dropIndex ( $ columns ) { $ index = new Index ( $ columns , $ this ) ; $ this -> actions [ ] = function ( ) use ( $ index ) { return $ this -> manipulation -> drop ( $ index ) ; } ; return $ this ; }
Drop a index on columns .
8,213
public static function generateAttribute ( string $ name , $ value ) : string { $ html = '' ; switch ( $ name ) { case 'autofocus' : case 'checked' : case 'disabled' : case 'hidden' : case 'ismap' : case 'multiple' : case 'novalidate' : case 'readonly' : case 'required' : case 'selected' : case 'spellcheck' : if ( ! em...
Returns a string with proper conversion of special characters to HTML entities of an attribute of a HTML tag .
8,214
public static function generateElement ( string $ tagName , array $ attributes = [ ] , ? string $ innerText = '' , bool $ isHtml = false ) : string { $ html = self :: generateTag ( $ tagName , $ attributes ) ; $ html .= ( $ isHtml ) ? $ innerText : self :: txt2Html ( $ innerText ) ; $ html .= '</' ; $ html .= $ tagName...
Generates HTML code for an element .
8,215
public static function generateTag ( string $ tagName , array $ attributes = [ ] ) : string { $ html = '<' ; $ html .= $ tagName ; foreach ( $ attributes as $ name => $ value ) { if ( strpos ( $ name , '_' ) !== 0 ) $ html .= self :: generateAttribute ( $ name , $ value ) ; } $ html .= '>' ; return $ html ; }
Generates HTML code for a start tag of an element .
8,216
public static function txt2Slug ( ? string $ string ) : string { if ( $ string === null ) return '' ; return trim ( preg_replace ( '/[^0-9a-z]+/' , '-' , strtr ( mb_strtolower ( $ string ) , self :: $ trans ) ) , '-' ) ; }
Returns the slug of a string that can be safely used in an URL .
8,217
private static function cleanClasses ( array $ classes ) : array { $ ret = [ ] ; foreach ( $ classes as $ class ) { $ tmp = Cast :: toManString ( $ class , '' ) ; if ( $ tmp !== '' ) $ ret [ ] = $ tmp ; } return array_unique ( $ ret ) ; }
Removes empty and duplicate classes from an array with classes .
8,218
public function toArray ( ) { $ ref = new \ ReflectionObject ( $ this ) ; $ export = array ( ) ; foreach ( $ ref -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ name = strtolower ( preg_replace ( '@([A-Z])@' , '_\1' , $ property -> getName ( ) ) ) ; $ export [ $ name ] = $ property -> ge...
Export dataWrapper values as an array
8,219
public function toCleanArray ( ) { $ export = $ this -> toArray ( ) ; $ cleanExport = array ( ) ; foreach ( $ export as $ key => $ value ) { if ( $ value ) { $ cleanExport [ $ key ] = $ value ; } } return $ cleanExport ; }
ToArray with unset null fields
8,220
public function getEngine ( ) { if ( $ this -> engine ) { return $ this -> engine ; } $ path = eve ( ) -> path ( 'template' ) ; $ this -> engine = eve ( 'handlebars' ) ; $ helpers = include ( __DIR__ . '/helpers.php' ) ; foreach ( $ helpers as $ name => $ callback ) { $ this -> engine -> registerHelper ( $ name , $ cal...
Returns the default template engine
8,221
protected function getTemplate ( ) { if ( ! $ this -> template ) { $ index = 'Action\\' ; $ root = strpos ( get_class ( $ this ) , $ index ) ; $ root += strlen ( $ index ) ; $ this -> template = eve ( 'string' ) -> set ( '\\' . substr ( get_class ( $ this ) , $ root ) ) -> str_replace ( '\\' , DIRECTORY_SEPARATOR ) -> ...
Returns file path used for templating
8,222
private function parse ( $ file , $ data = array ( ) , $ trigger = null ) { if ( is_null ( $ data ) ) { $ data = array ( ) ; } else if ( is_string ( $ data ) ) { $ trigger = $ data ; $ data = array ( ) ; } if ( $ trigger ) { eve ( ) -> trigger ( 'template-' . $ trigger , $ file , $ data ) ; } $ path = eve ( ) -> path (...
Returns the template loaded with specified data
8,223
public function isValidId ( ? string $ id ) : bool { if ( $ id == '' ) { return false ; } if ( $ this -> saveHandler != null && method_exists ( $ this -> saveHandler , 'isValidId' ) ) { return $ this -> saveHandler -> isValidId ( $ id ) ; } static $ idPattern ; if ( $ idPattern == null ) { if ( $ this -> options [ 'has...
Is valid id .
8,224
public function isValidSource ( ? string $ id ) : bool { if ( $ id == '' ) { return false ; } if ( $ this -> saveHandler != null && method_exists ( $ this -> saveHandler , 'isValidSource' ) ) { return $ this -> saveHandler -> isValidSource ( $ id ) ; } return file_exists ( $ this -> savePath . '/sess_' . $ id ) ; }
Is valid source .
8,225
public function generateId ( ) : string { if ( $ this -> saveHandler != null && method_exists ( $ this -> saveHandler , 'generateId' ) ) { return $ this -> saveHandler -> generateId ( $ id ) ; } $ id = session_create_id ( ) ; if ( $ this -> options [ 'hash' ] ) { switch ( $ this -> options [ 'hashLength' ] ) { case 32 ...
Generate id .
8,226
public function initLogoTypes ( ) { if ( isset ( $ this -> logoTypes ) ) { $ this -> _logoTypes = $ this -> logoTypes ; } else { $ this -> _logoTypes = [ ] ; } }
Init Logo Types
8,227
protected function get ( string & $ locale , string $ domain , string $ string ) : string { if ( $ this -> catalogueManager -> get ( $ locale ) -> has ( $ domain , $ string ) ) { return $ this -> catalogueManager -> get ( $ locale ) -> get ( $ domain , $ string ) ; } $ locale = $ this -> config -> getFallbackLocale ( )...
Get translation message from the locale bundle or fallback to default locale .
8,228
public static function interpolate ( string $ string , array $ values , string $ prefix = '{' , string $ postfix = '}' ) : string { $ replaces = [ ] ; foreach ( $ values as $ key => $ value ) { $ value = ( is_array ( $ value ) || $ value instanceof \ Closure ) ? '' : $ value ; try { $ value = is_object ( $ value ) ? ( ...
Interpolate string with given parameters used by many spiral components .
8,229
public function attachShared ( SharedEventManagerInterface $ sharedEm ) { $ this -> listeners [ ] = $ sharedEm -> attach ( $ this -> entityFormClass , 'init' , array ( $ this , 'onEntityFormInit' ) ) ; $ this -> listeners [ ] = $ sharedEm -> attach ( $ this -> entityFormClass , 'setData' , array ( $ this , 'onEntityFor...
Attach listeners to an event manager
8,230
public function detachShared ( SharedEventManagerInterface $ events ) { foreach ( $ this -> listeners as $ index => $ listener ) { if ( $ events -> detach ( $ listener ) ) { unset ( $ this -> listeners [ $ index ] ) ; } } }
Detach listeners from an event manager
8,231
public function procure ( Request $ request , Annotation $ annotation ) { $ read = $ this -> readSourceMethod ( $ request , $ annotation ) ; $ valueReader = $ request -> $ read ( $ annotation -> getParamName ( ) ) ; if ( $ annotation -> isRequired ( ) ) { return $ this -> filter ( $ valueReader -> required ( $ annotati...
extracts parameter from request and handles it
8,232
public function procureParam ( Param $ param , Annotation $ annotation ) { return $ this -> filter ( ValueReader :: forValue ( $ param -> value ( ) ) , $ annotation ) ; }
handles a single param
8,233
private function readSourceMethod ( Request $ request , Annotation $ annotation ) : string { $ method = 'read' . $ this -> source ( $ annotation ) ; if ( ! method_exists ( $ request , $ method ) ) { throw new \ RuntimeException ( 'Unknown source ' . $ annotation -> getSource ( ) . ' for ' . $ annotation . ' on ' . get_...
retrieves method to call on request instance
8,234
private function source ( Annotation $ annotation ) : string { if ( $ annotation -> hasValueByName ( 'source' ) ) { return ucfirst ( strtolower ( $ annotation -> getSource ( ) ) ) ; } return 'Param' ; }
returns source from where to read value
8,235
public function key ( ) { if ( $ this -> type == self :: PAIRS ) { return $ this -> current -> key ; } else { return $ this -> index ; } }
Return the current key
8,236
public function current ( ) { if ( $ this -> type == self :: KEYS ) { return $ this -> current -> key ; } else { return $ this -> current -> value ; } }
Return the current value
8,237
public function next ( ) { try { $ this -> current = $ this -> map -> successor ( $ this -> current ) ; } catch ( \ OutOfBoundsException $ e ) { $ this -> current = null ; } $ this -> index ++ ; }
Move forward to the next element
8,238
public function addDisplayGroup ( array $ elements , $ name ) { $ group = $ this -> newDisplayGroup ( ) ; foreach ( $ elements as $ element ) { if ( isset ( $ this -> _elements [ $ element ] ) ) { $ add = $ this -> getElement ( $ element ) ; if ( null !== $ add ) { $ group -> addElement ( $ add ) ; } } } if ( empty ( $...
Add a display group Groups named elements for display purposes .
8,239
public function getDateIntervalPropertyByUnit ( DateInterval $ diff , $ unit ) { if ( $ unit === 'seconds' ) { return $ diff -> s + $ diff -> i * 60 + $ diff -> h * 60 * 60 + $ diff -> days * 60 * 60 * 24 ; } if ( $ unit === 'minutes' ) { return $ diff -> i + $ diff -> h * 60 + $ diff -> days * 60 * 24 ; } if ( $ unit ...
Retrieve date interval property by unit .
8,240
public function convertTime ( string $ unit , float $ value ) { if ( $ unit === 'seconds' ) { return $ value ; } if ( $ unit === 'minutes' ) { return $ value * ( 60 ) ; } if ( $ unit === 'hours' ) { return $ value * ( 3600 ) ; } if ( $ unit === 'days' ) { return $ value * ( 86400 ) ; } if ( $ unit === 'weeks' ) { retur...
Converts to seconds .
8,241
public function cropCovers ( $ request ) { $ path = $ request [ 'path' ] ; $ coords = $ this -> getCropCoordinates ( $ request ) ; $ covers = $ this -> getNewCovers ( ) ; $ full = reset ( $ this -> _coverTypes ) ; $ cropperCover = $ this -> getTempCover ( ) ; $ cropperCover -> setResourceFromFile ( UPLOADS_PATH . 'tmp/...
Saves cropped covers
8,242
protected function prepareSessionData ( ) { if ( $ _SESSION === NULL ) return ; $ sessionClass = \ MvcCore \ Application :: GetInstance ( ) -> GetSessionClass ( ) ; $ sessionRawMetaStore = $ sessionClass :: GetSessionMetadata ( ) ; $ sessionMetaStore = $ sessionRawMetaStore instanceof \ stdClass ? $ sessionRawMetaStore...
Read and parse session data except MvcCore metadata session record .
8,243
private function _formateMaxLifeTimestamp ( $ timestamp = 0 ) { $ result = [ ] ; if ( $ timestamp >= 31557600 ) { $ localVal = floor ( $ timestamp / 31557600 ) ; $ result [ ] = $ localVal . ' year' . ( ( $ localVal > 1 ) ? 's' : '' ) ; if ( $ localVal > 1 ) return 'more than ' . $ result [ 0 ] ; $ timestamp = $ timesta...
Return expiration time in human readable format from seconds count .
8,244
public function uploadFileByFile ( UploadedFile $ file_request , $ fieldName , $ classFileString ) { $ file_content = file_get_contents ( $ file_request -> getPathname ( ) ) ; $ file_extension = $ file_request -> getClientOriginalExtension ( ) ; $ file_app_object = $ this -> writeFileBytes ( $ file_content , $ file_ext...
Guarda un fichero y devuelve su objeto File
8,245
private function createDir ( $ path ) { $ dir = $ path ; if ( ! is_dir ( $ dir ) ) { $ old = umask ( 0 ) ; mkdir ( $ dir , 0777 , true ) ; umask ( $ old ) ; chmod ( $ dir , 0777 ) ; } return $ dir ; }
Funcion para crear un directorio
8,246
private function bytes_to_file ( $ bytes , $ output_file ) { $ ifp = fopen ( $ output_file , "wb" ) ; fwrite ( $ ifp , $ bytes ) ; fclose ( $ ifp ) ; }
Pasa bytes a Fichero
8,247
private function writeFileBytes ( $ data_bytes , $ extension , $ field , $ classFileString ) { $ dir_rel = "uploads" . DIRECTORY_SEPARATOR . "gallery" . DIRECTORY_SEPARATOR ; $ dir = $ this -> createDir ( $ this -> getRoot ( ) . DIRECTORY_SEPARATOR . "web" . DIRECTORY_SEPARATOR . $ dir_rel ) ; $ file = new $ classFileS...
Escribe en un fichero sus Bytes crea el objeto File
8,248
private function defineParameters ( ContainerBuilder $ container ) { $ container -> setParameter ( 'dami.api.class' , 'Dami\Migration\Api\ApiMigration' ) ; $ container -> setParameter ( 'dami.template_renderer.class' , 'Dami\Migration\TemplateRenderer' ) ; $ container -> setParameter ( 'dami.template_initialization.cla...
Define parameters .
8,249
private function defineConnectionConfigParameter ( ContainerBuilder $ container , $ config ) { $ definition = new Definition ( 'Rentgen\Database\Connection\ConnectionConfig' ) ; $ definition -> setArguments ( array ( $ config [ 'environments' ] ) ) ; $ container -> setDefinition ( 'connection_config' , $ definition ) ;...
Define connection config parameters .
8,250
public function getErrorMessages ( $ recursive = false ) : ? array { $ ret = [ ] ; if ( $ recursive ) { foreach ( $ this -> controls as $ control ) { $ tmp = $ control -> getErrorMessages ( true ) ; if ( is_array ( $ tmp ) ) { $ ret = array_merge ( $ ret , $ tmp ) ; } } } if ( isset ( $ this -> errorMessages ) ) { $ re...
Returns an array of all error messages of the child form controls of this complex form controls .
8,251
public function prepare ( string $ parentSubmitName ) : void { parent :: prepare ( $ parentSubmitName ) ; foreach ( $ this -> controls as $ control ) { $ control -> prepare ( $ this -> submitName ) ; } }
Prepares this form complex control for HTML code generation or loading submitted values .
8,252
public function setValue ( $ values ) : void { foreach ( $ this -> controls as $ control ) { $ control -> setValuesBase ( $ values ) ; } }
Sets the values of the form controls of this complex control . The values of form controls for which no explicit value is set are set to null .
8,253
public function validateBase ( array & $ invalidFormControls ) : bool { $ valid = true ; foreach ( $ this -> controls as $ control ) { if ( ! $ control -> validateBase ( $ invalidFormControls ) ) { $ this -> invalidControls [ ] = $ control ; $ valid = false ; } } if ( $ valid ) { foreach ( $ this -> validators as $ val...
Executes a validators on the child form controls of this form complex control . If and only if all child form controls are valid the validators of this complex control are executed .
8,254
public function resolveInclude ( string $ relationName , array $ args ) { $ entity = $ args [ 0 ] ; $ relation = $ entity -> { $ relationName } ; if ( ! $ relation ) { return null ; } if ( $ relation instanceof Collection ) { if ( $ relation -> count ( ) === 0 ) { return null ; } $ classRelation = get_class ( $ relatio...
Resolve an include using the manager .
8,255
public function add ( $ name , $ direction ) { if ( ! in_array ( $ name , $ this -> keys , true ) ) { throw new Exceptions \ InvalidSorterFieldException ( $ name ) ; } if ( ! in_array ( $ direction , [ 'asc' , 'desc' ] , true ) ) { throw new Exceptions \ InvalidSorterDirectionException ( $ direction ) ; } $ field = new...
Perform the query and retrieve the information about pagination .
8,256
private function isValidJsonStructure ( string $ json ) : bool { if ( '{' === $ json [ 0 ] && $ json [ strlen ( $ json ) - 1 ] !== '}' ) { return false ; } elseif ( '[' === $ json [ 0 ] && $ json [ strlen ( $ json ) - 1 ] !== ']' ) { return false ; } elseif ( '{' !== $ json [ 0 ] && '[' !== $ json [ 0 ] ) { return fals...
checks if given json is valid a valid structure
8,257
public function addReferrerToForm ( FormInterface $ form ) : void { $ request = $ this -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; $ form -> add ( 'http-referrer' , HiddenType :: class , [ 'mapped' => false , 'data' => $ request -> headers -> get ( 'referer' ) , ] ) ; }
Add the current HTTP referrer header to the form
8,258
public function redirectToReferrer ( string $ defaultRoute = null ) : RedirectResponse { $ request = $ this -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; return $ this -> redirectToFirstValidRoute ( [ $ request -> headers -> get ( 'referer' ) , $ defaultRoute , ] ) ; }
Redirect to the referrer Falls back to the default route when no referrer is defined
8,259
public function redirectToFirstValidRoute ( array $ routeList ) : RedirectResponse { foreach ( $ routeList as $ route ) { if ( $ route ) { return $ this -> redirect ( $ route ) ; } } throw new \ InvalidArgumentException ( 'No valid route given' ) ; }
Redirect to the first valid route in the given list
8,260
public function required ( string $ errorId = 'FIELD_EMPTY' ) : valuereader \ CommonValueReader { if ( $ this -> value -> isNull ( ) ) { return new valuereader \ MissingValueReader ( function ( $ actualErrorId ) { $ this -> paramErrors -> append ( $ this -> paramName , $ actualErrorId ) ; } , $ errorId ) ; } return $ t...
enforce the value to be required
8,261
public function asBool ( ) { if ( $ this -> value -> isNull ( ) ) { return null ; } return $ this -> value -> isOneOf ( [ 1 , '1' , 'true' , true , 'yes' ] , true ) ; }
read as boolean value
8,262
public function asInt ( NumberRange $ range = null ) { return $ this -> handleFilter ( function ( ) use ( $ range ) { return filter \ RangeFilter :: wrap ( filter \ IntegerFilter :: instance ( ) , $ range ) ; } ) ; }
read as integer value
8,263
public function asSecret ( StringLength $ length = null ) { return $ this -> handleFilter ( function ( ) use ( $ length ) { return filter \ RangeFilter :: wrap ( filter \ SecretFilter :: instance ( ) , $ length ) ; } ) ; }
read as secret
8,264
public function asText ( StringLength $ length = null , array $ allowedTags = [ ] ) { return $ this -> handleFilter ( function ( ) use ( $ length , $ allowedTags ) { $ textFilter = new filter \ TextFilter ( ) ; return filter \ RangeFilter :: wrap ( $ textFilter -> allowTags ( $ allowedTags ) , $ length ) ; } ) ; }
read as text value
8,265
public function asJson ( int $ maxLength = filter \ JsonFilter :: DEFAULT_MAX_LENGTH ) { return $ this -> withFilter ( new filter \ JsonFilter ( $ maxLength ) ) ; }
read as json value
8,266
public function asHttpUri ( ) { if ( $ this -> value -> isEmpty ( ) ) { return null ; } if ( $ this -> value -> isHttpUri ( ) ) { return HttpUri :: fromString ( $ this -> value -> value ( ) ) ; } $ this -> paramErrors -> append ( $ this -> paramName , 'HTTP_URI_INCORRECT' ) ; return null ; }
read as http uri
8,267
public function asExistingHttpUri ( callable $ checkdnsrr = null ) { $ httpUri = $ this -> asHttpUri ( ) ; if ( null === $ httpUri ) { return null ; } if ( $ httpUri -> hasDnsRecord ( $ checkdnsrr ) ) { return $ httpUri ; } $ this -> paramErrors -> append ( $ this -> paramName , 'HTTP_URI_NOT_AVAILABLE' ) ; return null...
read as http uri if it does exist
8,268
public function ifIsIpAddress ( ) { if ( $ this -> value -> isIpAddress ( ) ) { return $ this -> value -> value ( ) ; } $ this -> paramErrors -> append ( $ this -> paramName , 'INVALID_IP_ADDRESS' ) ; return null ; }
returns value if it is an ip address and null otherwise
8,269
public function ifIsOneOf ( array $ allowedValues ) { if ( $ this -> value -> isOneOf ( $ allowedValues ) ) { return $ this -> value -> value ( ) ; } $ this -> paramErrors -> append ( $ this -> paramName , 'FIELD_NO_SELECT' , [ 'ALLOWED' => join ( '|' , $ allowedValues ) ] ) ; return null ; }
returns value if it is an allowed value according to list of allowed values and null otherwise
8,270
public function ifMatches ( string $ regex ) { if ( $ this -> value -> isMatchedBy ( $ regex ) ) { return $ this -> value -> value ( ) ; } $ this -> paramErrors -> append ( $ this -> paramName , 'FIELD_WRONG_VALUE' ) ; return null ; }
returns value if it is matched by given regular expression
8,271
public function when ( callable $ predicate , string $ errorId , array $ details = [ ] ) { return $ this -> handleFilter ( function ( ) use ( $ predicate , $ errorId , $ details ) { return new filter \ PredicateFilter ( $ predicate , $ errorId , $ details ) ; } ) ; }
returns param value when given predicate evaluates to true
8,272
private function handleFilter ( \ Closure $ createFilter ) { if ( $ this -> value -> isNull ( ) ) { return null ; } return $ this -> applyFilter ( $ createFilter ( ) ) ; }
handles a filter
8,273
public function withCallable ( callable $ filter ) { if ( $ this -> value -> isNull ( ) ) { return null ; } return $ this -> applyFilter ( new filter \ WrapCallableFilter ( $ filter ) ) ; }
checks value with given callable
8,274
public function activateOptions ( ) { try { $ this -> establishConnection ( ) ; } catch ( \ PDOException $ e ) { $ this -> warn ( "Failed connecting to database. Closing appender. Error: " . $ e -> getMessage ( ) ) ; $ this -> close ( ) ; return ; } $ pieces = explode ( ',' , $ this -> insertPattern ) ; $ converterMap ...
Acquires a database connection based on parameters . Parses the insert pattern to create a chain of converters which will be used in forming query parameters from logging events .
8,275
protected function establishConnection ( ) { $ this -> db = new \ PDO ( $ this -> dsn , $ this -> user , $ this -> password ) ; $ this -> db -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; $ insertSQL = str_replace ( '__TABLE__' , $ this -> table , $ this -> insertSQL ) ; $ this -> preparedInse...
Connects to the database and prepares the insert query .
8,276
public function append ( \ n2n \ log4php \ logging \ LoggingEvent $ event ) { for ( $ attempt = 1 ; $ attempt <= $ this -> reconnectAttempts + 1 ; $ attempt ++ ) { try { $ this -> preparedInsert -> execute ( $ this -> format ( $ event ) ) ; $ this -> preparedInsert -> closeCursor ( ) ; break ; } catch ( \ PDOException ...
Appends a new event to the database .
8,277
protected function format ( \ n2n \ log4php \ logging \ LoggingEvent $ event ) { $ params = array ( ) ; foreach ( $ this -> converters as $ converter ) { $ buffer = '' ; while ( $ converter !== null ) { $ converter -> format ( $ buffer , $ event ) ; $ converter = $ converter -> next ; } $ params [ ] = $ buffer ; } retu...
Converts the logging event to a series of database parameters by using the converter chain which was set up on activation .
8,278
public function setOrderBy ( $ sort , $ direction = 'ASC' ) { $ this -> sort = $ sort ; $ this -> direction = $ direction ; return $ this ; }
Sets th order by
8,279
public function get ( ) : array { try { $ query = $ this -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ compiled = $ this -> database -> getGrammar ( ) -> compileSelect ( $ query ) ; return $ this -> database -> select ( $ compiled -> getSQL ( ) , $ compiled -> getBindings ( ) ) ; } catch ( \ Throwable $ e...
Performs a select query and returns the selected rows . Doesn t modify itself .
8,280
public function first ( ) { try { $ query = ( clone $ this ) -> limit ( 1 ) -> apply ( $ this -> database -> getTablePrefixer ( ) ) ; $ compiled = $ this -> database -> getGrammar ( ) -> compileSelect ( $ query ) ; return $ this -> database -> selectFirst ( $ compiled -> getSQL ( ) , $ compiled -> getBindings ( ) ) ; }...
Performs a select query and returns the first selected row . Doesn t modify itself .
8,281
public function count ( $ column = '*' ) : int { try { return $ this -> getAggregate ( function ( Query $ query ) use ( $ column ) { $ query -> addCount ( $ column ) ; } ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Gets the count of the target rows . Doesn t modify itself .
8,282
public function avg ( $ column ) { try { return $ this -> getAggregate ( function ( Query $ query ) use ( $ column ) { $ query -> addAvg ( $ column ) ; } ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Gets the average value of the target rows . Doesn t modify itself .
8,283
public function sum ( $ column ) { try { return $ this -> getAggregate ( function ( Query $ query ) use ( $ column ) { $ query -> addSum ( $ column ) ; } ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Gets the sum of the target rows . Doesn t modify itself .
8,284
public function min ( $ column ) { try { return $ this -> getAggregate ( function ( Query $ query ) use ( $ column ) { $ query -> addMin ( $ column ) ; } ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Gets the minimum value of the target rows . Doesn t modify itself .
8,285
public function max ( $ column ) { try { return $ this -> getAggregate ( function ( Query $ query ) use ( $ column ) { $ query -> addMax ( $ column ) ; } ) ; } catch ( \ Throwable $ exception ) { return $ this -> handleException ( $ exception ) ; } }
Gets the maximum value of the target rows . Doesn t modify itself .
8,286
public function chunk ( int $ size , callable $ callback ) { if ( $ size <= 0 ) { $ this -> handleException ( new InvalidArgumentException ( 'Chunk size must be greater than zero' ) ) ; } $ query = clone $ this ; for ( $ offset = 0 ; ; $ offset += $ size ) { $ rows = $ query -> offset ( $ offset ) -> limit ( $ size ) -...
Walks large amount of rows calling a callback on small portions of rows . Doesn t modify itself .
8,287
public static function tearDown ( ) { $ dm = static :: $ dm ; if ( is_null ( $ dm ) ) { return ; } $ documents = [ 'Applications\Entity\Application' , 'Cv\Entity\Cv' , 'Jobs\Entity\Job' , 'Organizations\Entity\Organization' , 'Auth\Entity\User' , 'Jobs\Entity\Category' , 'Auth\Entity\UserImage' , 'Organizations\Entity\...
Empty all data every each tests
8,288
private function parse ( $ value ) : array { if ( is_array ( $ value ) ) { if ( $ value [ 0 ] !== $ value [ 1 ] ) { return $ this -> error ( 'PASSWORDS_NOT_EQUAL' ) ; } $ value = $ value [ 0 ] ; } if ( empty ( $ value ) === 0 ) { return [ null , [ ] ] ; } return [ Secret :: create ( $ value ) , [ ] ] ; }
parses password from given param value
8,289
public function clean ( $ value ) { $ cleaner = PruneWhitespaceCleaner :: get ( ) ; $ value = $ cleaner -> clean ( $ value ) ; if ( $ value === '' || $ value === null || $ value === false ) { return null ; } $ parts = parse_url ( $ value ) ; if ( ! is_array ( $ parts ) ) { return $ value ; } return Url :: unParseUrl ( ...
Returns a normalized URL if the submitted value is a URL . Otherwise returns the submitted value .
8,290
public function generate ( Exporter $ exporter , array $ data = [ ] ) { $ result = ( new DataBuilderManager ( ) ) -> validateRaw ( $ exporter -> data_builder , $ data ) ; if ( ! $ result -> ok ( ) ) { return $ result ; } $ className = $ exporter -> class_name ; if ( ! class_exists ( $ className ) ) { throw new \ Except...
Request a exporter .
8,291
public function format ( $ value ) { if ( $ value === null ) return null ; $ match = preg_match ( '/^(\d{4})-(\d{1,2})-(\d{1,2})$/' , $ value , $ parts ) ; $ valid = ( $ match && checkdate ( ( int ) $ parts [ 2 ] , ( int ) $ parts [ 3 ] , ( int ) $ parts [ 1 ] ) ) ; if ( $ valid ) { if ( $ value === $ this -> openDate ...
If the machine value is a valid date returns the date formatted according the format specifier . Otherwise returns the machine value unchanged .
8,292
public function parse ( $ input ) { if ( ! isset ( $ input ) ) { $ config = self :: $ defaultConfiguration ; } else if ( is_array ( $ input ) ) { $ config = $ input ; } else if ( is_string ( $ input ) ) { try { $ config = $ this -> parseFile ( $ input ) ; } catch ( \ n2n \ log4php \ LoggerException $ e ) { $ this -> wa...
Parses the given configuration and returns the parsed configuration as a PHP array . Does not perform any configuration .
8,293
private function parseFile ( $ url ) { if ( ! file_exists ( $ url ) ) { throw new \ n2n \ log4php \ LoggerException ( "File not found at [$url]." ) ; } $ type = $ this -> getConfigType ( $ url ) ; $ adapterClass = $ this -> adapters [ $ type ] ; $ adapter = new $ adapterClass ( ) ; return $ adapter -> convert ( $ url )...
Loads the configuration file from the given URL determines which adapter to use converts the configuration to a PHP array and returns it .
8,294
private function getConfigType ( $ url ) { $ info = pathinfo ( $ url ) ; $ ext = strtolower ( $ info [ 'extension' ] ) ; switch ( $ ext ) { case 'xml' : return self :: FORMAT_XML ; case 'ini' : case 'properties' : return self :: FORMAT_INI ; case 'php' : return self :: FORMAT_PHP ; default : throw new \ n2n \ log4php \...
Determines configuration file type based on the file extension .
8,295
private function doConfigure ( \ n2n \ log4php \ LoggerHierarchy $ hierarchy , $ config ) { if ( isset ( $ config [ 'threshold' ] ) ) { $ threshold = \ n2n \ log4php \ LoggerLevel :: toLevel ( $ config [ 'threshold' ] ) ; if ( isset ( $ threshold ) ) { $ hierarchy -> setThreshold ( $ threshold ) ; } else { $ this -> wa...
Constructs the logger hierarchy based on configuration .
8,296
private function createAppenderFilter ( \ n2n \ log4php \ LoggerAppender $ appender , $ config ) { $ name = $ appender -> getName ( ) ; $ class = $ config [ 'class' ] ; if ( ! class_exists ( $ class ) ) { $ this -> warn ( "Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition." ) ;...
Parses filter config creates the filter and adds it to the appender s filter chain .
8,297
private function configureRootLogger ( \ n2n \ log4php \ LoggerHierarchy $ hierarchy , $ config ) { $ logger = $ hierarchy -> getRootLogger ( ) ; $ this -> configureLogger ( $ logger , $ config ) ; }
Configures the root logger
8,298
private function configureOtherLogger ( \ n2n \ log4php \ LoggerHierarchy $ hierarchy , $ name , $ config ) { $ logger = $ hierarchy -> getLogger ( $ name ) ; $ this -> configureLogger ( $ logger , $ config ) ; }
Configures a logger which is not root .
8,299
private function configureLogger ( \ n2n \ log4php \ Logger $ logger , $ config ) { $ loggerName = $ logger -> getName ( ) ; if ( isset ( $ config [ 'level' ] ) ) { $ level = \ n2n \ log4php \ LoggerLevel :: toLevel ( $ config [ 'level' ] ) ; if ( isset ( $ level ) ) { $ logger -> setLevel ( $ level ) ; } else { $ this...
Configures a logger .