idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
1,200
public function setOptions ( array $ options = array ( ) ) { if ( sizeof ( $ this -> options ) == 0 ) { $ defaultOptions = array ( 'resizeUp' => false , 'jpegQuality' => 100 , 'correctPermissions' => false , 'preserveAlpha' => true , 'alphaMaskColor' => array ( 255 , 255 , 255 ) , 'preserveTransparency' => true , 'transparencyMaskColor' => array ( 0 , 0 , 0 ) , 'interlace' => null ) ; } else { $ defaultOptions = $ this -> options ; } $ this -> options = array_merge ( $ defaultOptions , $ options ) ; return $ this ; }
Sets options for all operations .
1,201
protected function calcImageSize ( $ width , $ height ) { $ newSize = array ( 'newWidth' => $ width , 'newHeight' => $ height ) ; if ( $ this -> maxWidth > 0 ) { $ newSize = $ this -> calcWidth ( $ width , $ height ) ; if ( $ this -> maxHeight > 0 && $ newSize [ 'newHeight' ] > $ this -> maxHeight ) { $ newSize = $ this -> calcHeight ( $ newSize [ 'newWidth' ] , $ newSize [ 'newHeight' ] ) ; } } if ( $ this -> maxHeight > 0 ) { $ newSize = $ this -> calcHeight ( $ width , $ height ) ; if ( $ this -> maxWidth > 0 && $ newSize [ 'newWidth' ] > $ this -> maxWidth ) { $ newSize = $ this -> calcWidth ( $ newSize [ 'newWidth' ] , $ newSize [ 'newHeight' ] ) ; } } $ this -> newDimensions = $ newSize ; }
Calculates the new image dimensions
1,202
protected function calcImageSizeStrict ( $ width , $ height ) { if ( $ this -> maxWidth >= $ this -> maxHeight ) { if ( $ width > $ height ) { $ newDimensions = $ this -> calcHeight ( $ width , $ height ) ; if ( $ newDimensions [ 'newWidth' ] < $ this -> maxWidth ) { $ newDimensions = $ this -> calcWidth ( $ width , $ height ) ; } } elseif ( $ height >= $ width ) { $ newDimensions = $ this -> calcWidth ( $ width , $ height ) ; if ( $ newDimensions [ 'newHeight' ] < $ this -> maxHeight ) { $ newDimensions = $ this -> calcHeight ( $ width , $ height ) ; } } } elseif ( $ this -> maxHeight > $ this -> maxWidth ) { if ( $ width >= $ height ) { $ newDimensions = $ this -> calcWidth ( $ width , $ height ) ; if ( $ newDimensions [ 'newHeight' ] < $ this -> maxHeight ) { $ newDimensions = $ this -> calcHeight ( $ width , $ height ) ; } } elseif ( $ height > $ width ) { $ newDimensions = $ this -> calcHeight ( $ width , $ height ) ; if ( $ newDimensions [ 'newWidth' ] < $ this -> maxWidth ) { $ newDimensions = $ this -> calcWidth ( $ width , $ height ) ; } } } $ this -> newDimensions = $ newDimensions ; }
Calculates new image dimensions not allowing the width and height to be less than either the max width or height
1,203
protected function preserveAlpha ( ) { if ( $ this -> format == 'PNG' && $ this -> options [ 'preserveAlpha' ] === true ) { imagealphablending ( $ this -> workingImage , false ) ; $ colorTransparent = imagecolorallocatealpha ( $ this -> workingImage , $ this -> options [ 'alphaMaskColor' ] [ 0 ] , $ this -> options [ 'alphaMaskColor' ] [ 1 ] , $ this -> options [ 'alphaMaskColor' ] [ 2 ] , 0 ) ; imagefill ( $ this -> workingImage , 0 , 0 , $ colorTransparent ) ; imagesavealpha ( $ this -> workingImage , true ) ; } if ( $ this -> format == 'GIF' && $ this -> options [ 'preserveTransparency' ] === true ) { $ colorTransparent = imagecolorallocate ( $ this -> workingImage , $ this -> options [ 'transparencyMaskColor' ] [ 0 ] , $ this -> options [ 'transparencyMaskColor' ] [ 1 ] , $ this -> options [ 'transparencyMaskColor' ] [ 2 ] ) ; imagecolortransparent ( $ this -> workingImage , $ colorTransparent ) ; imagetruecolortopalette ( $ this -> workingImage , true , 256 ) ; } }
Preserves the alpha or transparency for PNG and GIF files
1,204
public function getHandler ( string $ handlerName ) : ? IVfsHandler { return isset ( $ this -> _handlers [ $ handlerName ] ) ? $ this -> _handlers [ $ handlerName ] : null ; }
Gets the handler with defined name .
1,205
public function hasHandler ( $ handler ) : bool { if ( $ handler instanceof IVfsHandler ) { return isset ( $ this -> _handlers [ $ handler -> getName ( ) ] ) ; } if ( ! \ is_string ( $ handler ) ) { return false ; } return isset ( $ this -> _handlers [ $ handler ] ) ; }
Gets if the handler is defined .
1,206
public function onPostContentChange ( OrderEvent $ event ) { $ order = $ event -> getOrder ( ) ; if ( $ order -> getType ( ) == OrderTypes :: TYPE_CART ) { $ this -> provider -> setCart ( $ order ) ; } }
Order post content change event handler .
1,207
public function onPostStateChange ( OrderEvent $ event ) { $ order = $ event -> getOrder ( ) ; $ cart = $ this -> provider -> getCart ( ) ; if ( $ order -> getId ( ) === $ cart -> getId ( ) && $ order -> getType ( ) !== OrderTypes :: TYPE_CART ) { $ this -> provider -> clearCart ( ) ; } }
Order post state change event handler .
1,208
public function setConnectTimeout ( $ connectTimeout ) { $ this -> connectTimeout = ( float ) $ connectTimeout ; if ( $ this -> connectTimeout < 0 ) { throw new InvalidArgumentException ( 'connect timeout < 0' ) ; } return $ this ; }
Setter of connection timeout parameter
1,209
public function setConnectTries ( $ connectTries ) { $ this -> connectTries = ( int ) $ connectTries ; if ( $ this -> connectTries < 1 ) { throw new InvalidArgumentException ( 'connect tries < 1' ) ; } return $ this ; }
Setter of number of connection tries
1,210
public function setHost ( $ host ) { $ this -> host = ( string ) $ host ; if ( empty ( $ this -> host ) ) { throw new InvalidArgumentException ( 'empty host' ) ; } return $ this ; }
Setter for instance host
1,211
public function setPort ( $ port ) { $ this -> port = $ port ; if ( $ this -> port < 0 || $ this -> port > 65535 ) { throw new InvalidArgumentException ( 'connection post is out of range' ) ; } return $ this ; }
Setter of instance connection port
1,212
public function touch ( $ path , $ time = null , $ atime = null , $ force = false ) { if ( $ force ) { $ time ? @ touch ( $ path , $ time , $ atime ) : @ touch ( $ path ) ; } else { $ time ? touch ( $ path , $ time , $ atime ) : touch ( $ path ) ; } }
Touch a file to set access and modifiction time .
1,213
public static function error_php ( $ type , $ level , $ message , $ file , $ line ) { self :: write_log ( $ message , $ type , $ file , $ line ) ; if ( error_reporting ( ) ) { include PATHAPP . 'errors-info/error_php.php' ; } }
Crea una respuesta de error php - usada por el manejador de errores definido por el framework Escribe en log
1,214
public static function write_log ( $ chain , $ type , $ file = "" , $ line = "" ) { $ arch = fopen ( PATHAPP . 'logs/log-' . date ( 'Y-m-d' ) . '.txt' , "a+" ) ; if ( ENOLA_MODE == 'HTTP' ) { fwrite ( $ arch , "[" . date ( "Y-m-d H:i:s.u" ) . " " . filter_input ( INPUT_SERVER , 'REMOTE_ADDR' ) . " " . " - $type ] " . $ chain . " - $file - $line \n" ) ; } else { fwrite ( $ arch , "[" . date ( "Y-m-d H:i:s.u" ) . " MODE CLI " . " - $type ] " . $ chain . " - $file - $line \n" ) ; } fwrite ( $ arch , "---------- \n" ) ; fclose ( $ arch ) ; }
Crea o abre un archivo de log y escribe el error correspondiente Escribe en log
1,215
public static function catch_server_error ( ) { $ enolaError = filter_input ( INPUT_GET , 'error_apache_enola' ) ; if ( $ enolaError ) { $ errores = UrlUri :: httpStates ( ) ; self :: write_log ( 'error_http' , $ errores [ $ enolaError ] ) ; self :: general_error ( 'Error ' . $ enolaError , $ errores [ $ enolaError ] , 'general_error' , $ enolaError ) ; exit ; } }
Analiza si se envia a traves de un parametro get un error HTTP Escribe en log
1,216
private function convertProperty ( $ name ) { if ( isset ( $ this -> _schema [ $ name ] [ 'null' ] ) && $ this -> _schema [ $ name ] [ 'null' ] && $ this -> $ name === null ) { return ; } switch ( $ this -> _schema [ $ name ] [ 'type' ] ) { case Object :: TYPE_ID : if ( ! ( $ this -> $ name instanceof MongoId ) && $ this -> $ name !== null ) { $ this -> $ name = new MongoId ( $ this -> $ name ) ; } break ; case Object :: TYPE_BOOL : if ( ! is_bool ( $ this -> $ name ) ) { $ this -> $ name = ( bool ) $ this -> $ name ; } break ; case Object :: TYPE_INT : if ( ! is_int ( $ this -> $ name ) ) { $ this -> $ name = ( int ) $ this -> $ name ; } break ; case Object :: TYPE_DOUBLE : if ( ! is_double ( $ this -> $ name ) ) { $ this -> $ name = ( double ) $ this -> $ name ; } break ; case Object :: TYPE_STRING : if ( ! is_string ( $ this -> $ name ) ) { $ this -> $ name = ( string ) $ this -> $ name ; } break ; case Object :: TYPE_ARRAY : if ( ! is_array ( $ this -> $ name ) ) { $ this -> $ name = [ ] ; } break ; case Object :: TYPE_DATE : if ( ! ( $ this -> $ name instanceof MongoDate ) ) { $ this -> $ name = new MongoDate ( $ this -> $ name ) ; } break ; case Object :: TYPE_REFERENCE : if ( ! MongoDBRef :: isRef ( $ this -> $ name ) ) { $ this -> $ name = null ; } break ; default : throw new Exception ( "Property '{$name}' type is unknown ({$this->_schema[$name]['type']})" ) ; } return null ; }
Check that property conforms to schema and convert it if needed
1,217
protected function getData ( ) { $ data = [ ] ; foreach ( $ this -> _schema as $ name => $ desc ) { $ data [ $ name ] = $ this -> $ name ; if ( isset ( $ desc [ 'updateDate' ] ) && $ desc [ 'updateDate' ] ) { $ data [ $ name ] = new MongoDate ( ) ; } } if ( $ data [ '_id' ] === null ) { unset ( $ data [ '_id' ] ) ; } return $ data ; }
Get data of this object as array
1,218
public function save ( ) { $ data = $ this -> getData ( ) ; if ( $ this -> _collection -> save ( $ data , [ "j" => true ] ) [ 'err' ] === null ) { $ this -> _id = $ data [ '_id' ] ; $ this -> _cache -> store ( static :: getCollection ( ) . "_{$this->_id}" , $ data ) ; return true ; } return false ; }
Save object into Mongo collection
1,219
public function delete ( ) { if ( ! $ this -> isNew ( ) ) { $ this -> _collection -> remove ( [ '_id' => $ this -> _id ] ) ; $ this -> _cache -> delete ( static :: getCollection ( ) . "_{$this->_id}" ) ; return true ; } return false ; }
Delete object from Mongo collection
1,220
public function getDBRef ( ) { return $ this -> isNew ( ) ? null : MongoDBRef :: create ( $ this -> _collection -> getName ( ) , $ this -> _id ) ; }
Get Mongo DBRef object pointing to this object
1,221
protected function fetchDBRef ( $ typeName , $ dbref ) { $ typeName = $ this -> getFullType ( $ typeName ) ; if ( class_exists ( $ typeName ) && MongoDBRef :: isRef ( $ dbref ) ) { $ collectionName = $ typeName :: getCollection ( ) ; $ collection = $ this -> _collection -> db -> $ collectionName ; $ data = $ this -> _cache -> fetch ( "{$collectionName}_{$dbref['$id']}" ) ; if ( $ data === null ) { $ data = $ this -> _collection -> getDBRef ( $ dbref ) ; } if ( $ data === null ) { return null ; } return new $ typeName ( $ data , $ collection , $ this -> _cache ) ; } return null ; }
Fetch object using MongoDBRef
1,222
public function refresh ( ) { if ( $ this -> _id !== null ) { $ data = $ this -> _collection -> findOne ( [ '_id' => $ this -> _id ] ) ; foreach ( $ this -> _schema as $ name => $ desc ) { if ( isset ( $ data [ $ name ] ) ) { $ this -> $ name = $ data [ $ name ] ; } } } }
Reload data from Mongo
1,223
public function jsonSerialize ( ) { $ jsonData = $ this -> getData ( ) ; if ( isset ( $ jsonData [ "_id" ] ) ) { $ jsonData [ "id" ] = ( string ) $ jsonData [ "_id" ] ; unset ( $ jsonData [ "_id" ] ) ; } foreach ( $ this -> _schema as $ name => $ dsc ) { if ( @ $ dsc [ 'hidden' ] ) { unset ( $ jsonData [ $ name ] ) ; } } return $ jsonData ; }
Get array of data for JSON serialization
1,224
public function mergeData ( array $ data ) { foreach ( $ data as $ name => $ val ) { if ( isset ( $ this -> _schema [ $ name ] ) ) { $ this -> $ name = $ val ; $ this -> convertProperty ( $ name ) ; } } }
Merge properties values from another array
1,225
public function setAction ( $ action , $ isAjax = true ) { $ this -> action = $ action ; foreach ( $ this -> suggestCells as $ cell ) { $ cell -> setAjaxElement ( $ isAjax ) ; $ cell -> setAction ( $ action ) ; } }
sets the action to all list items
1,226
public function handle ( array $ record ) { $ e = Arr :: path ( $ record , 'context.exception' ) ; if ( $ e !== null and $ e instanceof DummyException ) { return false ; } return $ this -> handler -> handle ( $ record ) ; }
Wrap the handle function and only allow a record through if it is not a DummyException
1,227
static function array2object ( array $ arr , $ class = 'StdClass' ) { $ obj = new $ class ; foreach ( $ arr as $ key => $ value ) { $ obj -> { $ key } = is_array ( $ value ) ? static :: array2object ( $ value , $ class ) : $ value ; } return $ obj ; }
Recursively converts array into an object
1,228
static function object2array ( $ obj ) { $ arr = [ ] ; foreach ( $ obj as $ key => $ value ) { $ arr [ $ key ] = is_object ( $ value ) ? static :: object2array ( $ value ) : $ value ; } return $ arr ; }
Recursively converts an object into array
1,229
protected function completeResponse ( EventManagerInterface $ events , MvcEvent $ event , ResponseInterface $ response ) { $ event -> setName ( MvcEvent :: EVENT_FINISH ) ; $ event -> setTarget ( $ this ) ; $ event -> setResponse ( $ response ) ; $ event -> stopPropagation ( false ) ; $ events -> triggerEvent ( $ event ) ; $ this -> response = $ response ; return $ this ; }
Complete the request response . Triggers finish events and returns current application instance .
1,230
public function getOutput ( $ offset = null ) { if ( ! $ this -> logFile ) { return '' ; } return ( string ) file_get_contents ( $ this -> logFile , FILE_BINARY , null , $ offset ) ; }
Retrieve the current output .
1,231
public function perform ( $ logFile ) { if ( self :: STATE_PENDING !== $ this -> getStatus ( ) ) { throw new \ LogicException ( 'Attempted to run task ' . $ this -> getId ( ) . ' twice.' ) ; } try { if ( ! is_dir ( dirname ( $ logFile ) ) ) { mkdir ( dirname ( $ logFile ) , 0777 , true ) ; } file_put_contents ( $ logFile , '' , FILE_BINARY ) ; $ this -> logFile = $ logFile ; $ this -> file -> set ( 'log' , $ logFile ) ; $ this -> setStatus ( self :: STATE_RUNNING ) ; $ this -> addOutput ( 'Task ' . $ this -> getId ( ) . ' started.' . "\n" ) ; $ this -> doPerform ( ) ; } catch ( \ Exception $ exception ) { $ this -> addOutput ( '--------------------------------------------------------' . "\n" ) ; $ this -> addOutput ( 'Exception occured: ' . $ exception -> getMessage ( ) . "\n" ) ; $ this -> addOutput ( $ exception -> getTraceAsString ( ) . "\n" ) ; $ loopException = $ exception ; while ( $ loopException = $ loopException -> getPrevious ( ) ) { $ this -> addOutput ( 'Chained exception: ' . $ loopException -> getMessage ( ) . "\n" ) ; $ this -> addOutput ( $ loopException -> getTraceAsString ( ) . "\n" ) ; } $ this -> addOutput ( '--------------------------------------------------------' . "\n" ) ; $ this -> setStatus ( self :: STATE_ERROR ) ; throw new \ RuntimeException ( 'Task ' . $ this -> getId ( ) . ' errored: ' . $ exception -> getMessage ( ) , 1 , $ exception ) ; } $ this -> addOutput ( 'Finished without error.' . "\n" ) ; $ this -> setStatus ( self :: STATE_FINISHED ) ; }
Perform the task .
1,232
public function addOutput ( $ string ) { if ( ! $ this -> logFile ) { throw new \ LogicException ( 'The has not started to run yet.' ) ; } file_put_contents ( $ this -> logFile , $ string , ( FILE_APPEND | FILE_BINARY ) ) ; }
Add some output .
1,233
public function getIO ( ) { if ( ! isset ( $ this -> inputOutput ) ) { $ this -> inputOutput = new ConsoleIO ( $ this -> getInput ( ) , new TaskOutput ( $ this ) , new HelperSet ( [ ] ) ) ; } return $ this -> inputOutput ; }
Retrieve the IO interface .
1,234
public function removeAssets ( ) { if ( $ this -> logFile ) { if ( file_exists ( $ this -> logFile ) ) { unlink ( $ this -> logFile ) ; } $ this -> logFile = null ; $ this -> file -> remove ( 'log' ) ; } }
Remove the attached files for this task from disk .
1,235
public function getUrl ( $ path ) { $ regExp = '/\/\/|https?:/i' ; if ( preg_match ( $ regExp , $ path ) ) { return $ path ; } try { $ generated = call_user_func_array ( [ $ this -> getRouterGenerator ( ) , 'generate' ] , func_get_args ( ) ) ; } catch ( AuraException $ caught ) { $ generated = false ; } $ basePath = rtrim ( $ this -> getRequest ( ) -> getBasePath ( ) , '/' ) ; $ path = $ generated ? $ generated : "{$basePath}/{$path}" ; return $ path ; }
Gets the url for provided path
1,236
protected function hasInternalMethod ( string $ name ) : bool { static $ methods = [ ] ; $ class = get_class ( $ this ) ; if ( isset ( $ methods [ $ class ] [ $ name ] ) ) { return $ methods [ $ class ] [ $ name ] ; } $ hasMethod = ( new ReflectionClass ( $ this ) ) -> hasMethod ( $ name ) ; $ methods [ $ class ] [ $ name ] = $ hasMethod ; return $ hasMethod ; }
Check if this component has a method of the given name
1,237
private function insert ( $ index , $ type , $ hrefOrCss ) { self :: $ cssList -> insert ( $ index , array ( $ type , $ hrefOrCss ) ) ; return $ this ; }
Insert a css to css list
1,238
public function renderIdentity ( IdentityInterface $ identity , $ long = false ) { return sprintf ( '%s %s %s' , $ this -> translator -> trans ( $ this -> getGenderLabel ( $ identity -> getGender ( ) , $ long ) ) , $ identity -> getFirstName ( ) , $ identity -> getLastName ( ) ) ; }
Renders the identity .
1,239
protected function registerService ( ) { $ this -> app -> singleton ( $ this -> getProviderKey ( ) , function ( $ app ) { return new Service ( $ this -> getProviderKey ( ) , null , $ this -> getAggregateService ( ) ) ; } ) ; }
Register Service .
1,240
protected function registerCore ( ) { $ this -> app -> singleton ( IdentifierServiceProvider :: getProviderKey ( ) , function ( $ app ) { return new IdentifierService ( IdentifierServiceProvider :: getProviderKey ( ) , new IdentifierDataSource ( new IdentifierModel ( [ ] , $ this -> getConnection ( ) ) ) ) ; } ) ; $ this -> app -> singleton ( ReferenceServiceProvider :: getProviderKey ( ) , function ( $ app ) { return new ReferenceService ( ReferenceServiceProvider :: getProviderKey ( ) , new ReferenceDataSource ( new ReferenceModel ( [ ] , $ this -> getConnection ( ) ) ) ) ; } ) ; }
Register Core Services used by this Service .
1,241
public function getByKey ( $ key , $ locale , $ group = null ) { $ query = $ this -> source -> select ( 'languages.slug as locale' , 'translations.*' ) -> join ( 'languages' , 'languages.id' , '=' , 'translations.language_id' ) -> where ( 'languages.slug' , $ locale ) -> whereKey ( $ key ) ; if ( $ group ) $ query -> where ( 'group' , $ group ) ; return $ query -> first ( ) ; }
Get local by key .
1,242
protected function _resolveDefinition ( $ definition ) { if ( ! is_callable ( $ definition ) ) { return $ definition ; } try { $ args = $ this -> _normalizeArray ( $ this -> _getArgsForDefinition ( $ definition ) ) ; return $ this -> _invokeCallable ( $ definition , $ args ) ; } catch ( RootException $ e ) { throw $ this -> _createRuntimeException ( $ this -> __ ( 'Could not resolve definition' ) , null , $ e ) ; } }
Resolves a service definition .
1,243
public function findSoft ( $ column , $ value ) { return $ this -> getFirstSoft ( ( is_null ( $ column ) ? $ this -> key : $ column ) . ' = ?' , [ $ value ] ) ; }
Find and return first entry by key ignoring soft - deleted entries .
1,244
public function getFirstSoft ( $ conditions = null , $ values = [ ] , $ options = [ ] ) { return $ this -> processSingleResult ( $ this -> executeQuerySoft ( null , $ conditions , $ values , $ options ) ) ; }
Retrieve first entry ignoring soft - deleted ones optionally filtered by search criteria .
1,245
public function getAllSoft ( $ conditions = null , $ values = [ ] , $ options = [ ] ) { return $ this -> processMultipleResults ( $ this -> executeQuerySoft ( null , $ conditions , $ values , $ options ) ) ; }
Retrieve all entries ignoring soft - deleted ones optionally filtered by search criteria .
1,246
public function countSoft ( $ conditions = null , $ values = [ ] ) { $ res = $ this -> executeQuerySoft ( 'COUNT(' . $ this -> key . ') AS num' , $ conditions , $ values ) -> fetch ( ) ; return ( isset ( $ res -> num ) ? ( int ) $ res -> num : 0 ) ; }
Count entries ignoring soft - deleted ones optionally filtered by search criteria .
1,247
protected function executeQuerySoft ( $ select = null , $ conditions = null , $ values = [ ] , $ options = [ ] ) { $ delCond = $ this -> deleted . ' IS NULL' ; $ conditions = ( is_null ( $ conditions ) ? $ delCond : "($conditions) AND $delCond" ) ; return $ this -> executeQuery ( $ select , $ conditions , $ values , $ options ) ; }
Execute soft - deletion - aware query for selection methods .
1,248
public function actionMigrate ( $ operation = 'up' ) { if ( $ this -> confirm ( "Migrate {$operation} migration: " . $ this -> migration ) ) { $ migration = Yii :: createObject ( $ this -> migration ) ; $ migration -> { $ operation } ( ) ; } else { $ this -> stdout ( 'User abort.' . PHP_EOL , Console :: FG_YELLOW ) ; } return 0 ; }
Run migration with FQN of a migration class .
1,249
public function consoleLog ( $ msg , $ enableTS = true , $ fgColor = null , $ returnLine = true , $ padLength = false ) { if ( $ enableTS ) { $ msg = '[' . date ( 'Y-m-d H:i:s' ) . '] ' . $ msg ; } if ( $ padLength ) { $ msg = str_pad ( $ msg , $ padLength , '.' , STR_PAD_RIGHT ) ; } if ( $ returnLine ) { $ msg .= PHP_EOL ; } $ this -> stdout ( $ msg , $ fgColor ) ; }
Log method .
1,250
public function build ( ) { switch ( $ this -> type ) { case 'asset' : return $ this -> getBuildAsset ( ) ; break ; case 'page' : return $ this -> getBuildPage ( ) ; break ; case 'post' : return $ this -> getBuildPost ( ) ; break ; case 'category' : return $ this -> getBuildCategory ( ) ; break ; case 'pagination' : return $ this -> getBuildPagination ( ) ; break ; case 'author' : return $ this -> getBuildAuthor ( ) ; break ; case 'site' : return new BuildSite ( $ this -> config , $ this -> getBuildAsset ( ) , $ this -> getBuildPage ( ) , $ this -> getBuildPost ( ) , $ this -> getBuildCategory ( ) , $ this -> getBuildPagination ( ) , $ this -> getBuildAuthor ( ) ) ; break ; default : return ; break ; } }
Main method to get class instance of BuildNode
1,251
public function getBuildPagination ( ) { $ buildPost = $ this -> getBuildPost ( ) ; $ buildPost -> build ( ) ; return new BuildPagination ( $ this -> config , $ buildPost -> getNodes ( ) ) ; }
Get instance of BuildPagination
1,252
public function getBuildAuthor ( ) { $ buildPost = $ this -> getBuildPost ( ) ; $ buildPost -> build ( ) ; return new BuildAuthor ( $ this -> config , $ buildPost -> getNodes ( ) ) ; }
Get instance of BuildAuthor
1,253
public function read ( $ source ) { $ dom = $ this -> getDomParser ( ) -> parse ( $ source ) ; foreach ( $ this -> getStandards ( ) as $ standard ) { if ( $ standard -> canHandle ( $ dom ) ) { return $ standard -> getParser ( ) -> parse ( $ dom ) ; } } throw new UnknownFeedFormatException ( ) ; }
Turn a source string into a feed object .
1,254
public static function toAssoc ( array $ response ) { $ out = [ ] ; $ count = count ( $ response ) ; for ( $ i = 1 ; $ i < $ count ; $ i += 2 ) { $ out [ $ response [ $ i - 1 ] ] = $ response [ $ i ] ; } return $ out ; }
Map RESP responses to an associative array .
1,255
public static function unFormat ( $ number ) { $ number = str_replace ( '.' , 'D' , $ number ) ; $ number = str_replace ( ',' , '' , $ number ) ; $ number = str_replace ( 'D' , '.' , $ number ) ; return $ number ; }
UnFormats a formatted number .
1,256
public function bindValues ( $ sql , array & $ bindings , array $ settings ) { $ this -> setEscapeCallable ( $ settings [ 'escapeFunction' ] ) ; return preg_replace_callback ( '/\b__PHQUERY_[^_]++__\b/' , function ( $ m ) use ( & $ bindings , $ settings ) { return $ this -> replacePlaceholders ( $ m [ 0 ] , $ bindings , $ settings ) ; } , $ sql ) ; }
Replace placeholders in the SQL with ? or real value
1,257
public function replaceQuestionMark ( $ string , array $ values ) { $ pat = $ rep = [ ] ; foreach ( $ values as $ val ) { $ pat [ ] = '/\?/' ; $ rep [ ] = $ this -> getPlaceholder ( $ val ) ; } return preg_replace ( $ pat , $ rep , $ string , 1 ) ; }
Replace ? in the string with placeholders for value .
1,258
public static function setDefaultCallBehavior ( $ behavior ) { if ( $ behavior instanceof \ Closure ) { self :: $ __defaultCallBehavior = $ behavior ; return ; } switch ( $ behavior ) { case self :: DEFAULT_BEHAVIOUR_RETURN_NULL : case self :: DEFAULT_BEHAVIOUR_RETURN_SELF ; case self :: DEFAULT_BEHAVIOUR_THROW_EXCEPTION : self :: $ __defaultCallBehavior = $ behavior ; return ; } throw new \ InvalidArgumentException ( "Invalid behavior option ($behavior)" ) ; }
Set default method call behavior
1,259
private function __callTraitMethods ( $ name , $ arguments ) { $ result = next :: caller ( ) ; $ traitMethods = $ this -> getTraitMethods ( ) ; if ( ! isset ( $ traitMethods [ $ name ] ) ) { return $ result ; } $ method = $ this -> __reflection ( ) -> getMethod ( $ name ) ; if ( ! $ method -> isPublic ( ) && ! $ this -> __enableClassScope ) { return $ result ; } $ methods = $ traitMethods [ $ name ] ; $ methods = array_reverse ( $ methods ) ; $ scope = $ this ; $ level = - 1 ; $ parent = function ( $ arguments ) use ( $ scope , $ methods , & $ level ) { $ level ++ ; if ( $ level >= count ( $ methods ) ) { return next :: caller ( ) ; } $ result = call_user_func_array ( [ $ scope , $ methods [ $ level ] ] , $ arguments ) ; $ level -- ; return $ result ; } ; next :: __registerParentCallback ( $ parent ) ; $ result = $ parent ( $ arguments ) ; next :: __registerParentCallback ( null ) ; return $ result ; }
Call all registered trait methods
1,260
private function __processDefaultMethodCall ( $ name , $ arguments ) { if ( self :: $ __defaultCallBehavior instanceof \ Closure ) { $ handle = self :: $ __defaultCallBehavior ; $ handle = $ handle -> bindTo ( $ this ) ; return call_user_func_array ( $ handle , $ arguments ) ; } switch ( self :: $ __defaultCallBehavior ) { case self :: DEFAULT_BEHAVIOUR_RETURN_NULL : if ( $ name === '__toString' ) { return '' ; } return null ; case self :: DEFAULT_BEHAVIOUR_RETURN_SELF : if ( $ name === '__toString' ) { return '' ; } return $ this ; } throw new \ BadMethodCallException ( sprintf ( 'Method %s::%s() does not exist' , get_class ( $ this ) , $ name ) ) ; }
Process default method call behavior
1,261
private function __callClosureFunction ( $ name , $ arguments ) { $ result = next :: caller ( ) ; if ( ! isset ( $ this -> __properties [ $ name ] ) ) { return $ result ; } if ( ! $ this -> __properties [ $ name ] instanceof \ Closure ) { return $ result ; } $ callable = $ this -> __properties [ $ name ] ; $ callable = $ callable -> bindTo ( $ this ) ; $ this -> allowPrivateScope ( ) ; try { $ result = call_user_func_array ( $ callable , $ arguments ) ; $ this -> disallowPrivateScope ( ) ; } catch ( \ Exception $ e ) { $ this -> disallowPrivateScope ( ) ; throw $ e ; } return $ result ; }
Call closure function if exist
1,262
public function __callProtectedMethod ( $ name , $ arguments = [ ] ) { try { $ method = $ this -> __reflection ( ) -> getMethod ( $ name ) ; } catch ( \ Exception $ e ) { return next :: caller ( ) ; } $ method -> setAccessible ( true ) ; $ result = $ method -> invokeArgs ( $ this , $ arguments ) ; $ method -> setAccessible ( false ) ; return $ result ; }
Helper method to call a protected method from outside
1,263
private function __reflection ( ) { if ( ! $ this -> __reflection ) { $ this -> __reflection = new \ ReflectionClass ( get_class ( $ this ) ) ; } return $ this -> __reflection ; }
Retrieve a reflection of the current class
1,264
private function getTraitMethods ( ) { if ( ! is_array ( $ this -> _traitMethods ) ) { $ this -> _traitMethods = $ this -> mergeTraitMethods ( ) ; } return $ this -> _traitMethods ; }
Retrieve all trait methods
1,265
private function mergeTraitMethods ( ) { $ reflection = $ this -> __reflection ( ) ; $ mergedMethods = [ ] ; do { $ staticProperties = $ reflection -> getStaticProperties ( ) ; if ( ! isset ( $ staticProperties [ ' classMocker_traitMethods' ] ) ) { continue ; } $ mergedMethods = array_merge_recursive ( $ mergedMethods , $ staticProperties [ ' classMocker_traitMethods' ] ) ; } while ( $ reflection = $ reflection -> getParentClass ( ) ) ; return $ mergedMethods ; }
Merge all trait methods from all parents
1,266
public function random ( ) { $ keys = array_keys ( $ this -> elements ) ; return $ this -> elements [ $ keys [ rand ( 0 , sizeof ( $ keys ) - 1 ) ] ] ; }
Sets the internal iterator to the last element in the collection and returns this element .
1,267
public function removeFind ( string $ method , $ value ) : self { $ list = $ this -> find ( $ method , $ value ) ; foreach ( $ list as $ element ) { $ this -> removeInstance ( $ element ) ; } return $ list ; }
Remove from current all element find by property or method value .
1,268
public function diff ( Collection $ collection ) : self { foreach ( $ this -> elements as $ element ) { if ( ! $ collection -> contains ( $ element ) ) { $ this -> removeElement ( $ element ) ; } } foreach ( $ collection as $ element ) { if ( ! $ this -> contains ( $ element ) ) { $ this -> add ( $ element ) ; } } return $ this ; }
Compare with current collection add missing remove unnecessary on current .
1,269
public function call ( string $ method , ... $ vars ) : self { $ clone = clone $ this ; $ clone -> elements = array_map ( function ( $ element ) use ( $ method , $ vars ) { return call_user_func_array ( [ $ element , $ method ] , $ vars ) ; } , $ this -> elements ) ; return $ clone ; }
Call the given method to each element in the collection and returns a new collection with return values for each call .
1,270
public function find ( string $ method , $ value , array $ args = [ ] ) { $ isMethod = null ; $ clone = clone $ this ; $ clone -> elements = array_filter ( $ this -> elements , function ( $ item ) use ( $ method , $ value , & $ isMethod , $ args ) { return $ this -> elementMethodCall ( $ method , $ item , $ isMethod , $ args ) === $ value ; } ) ; return $ clone ; }
Return a new collection find by property or method value .
1,271
public function findOne ( string $ method , $ value , array $ args = [ ] ) { $ return = $ this -> find ( $ method , $ value , $ args ) ; if ( $ return -> count ( ) > 1 ) { throw new \ OverflowException ( sprintf ( "Too many element return (%s), needed only one for '%s' = '%s'" , $ return -> count ( ) , $ method , is_object ( $ value ) ? get_class ( $ value ) : $ value ) ) ; } return $ return -> count ( ) ? $ return -> first ( ) : null ; }
Return one element find by property or method value .
1,272
public function partitions ( callable $ callable ) : array { $ return = [ ] ; foreach ( $ this -> elements as $ key => $ element ) { $ value = $ callable ( $ element , $ key ) ; if ( ! isset ( $ return [ $ value ] ) ) { $ return [ $ value ] = clone $ this ; $ return [ $ value ] -> elements = [ ] ; } $ return [ $ value ] -> add ( $ element ) ; } return $ return ; }
Partitions this collection in collections according to a predicate returnr value . Keys are not preserved in the resulting collections .
1,273
public function merge ( Collection $ collection ) : self { $ return = clone $ this ; $ return -> elements = array_merge ( $ return -> elements , $ collection -> elements ) ; return $ return ; }
Merge current collection and passed collection . Return a new collection instance and don t alter current one .
1,274
public function swapIndex ( $ index , $ newIndex ) : bool { if ( $ newIndex < 0 || $ newIndex > sizeof ( $ this -> elements ) ) { return false ; } $ object = $ this -> elements [ $ index ] ; $ newObject = $ this -> elements [ $ newIndex ] ; $ this -> elements [ $ newIndex ] = $ object ; $ this -> elements [ $ index ] = $ newObject ; return true ; }
Swap 2 elements by index
1,275
public function getReplaces ( ) { return [ "<header>" => Colors :: COLOR_FGL_WHITE . Colors :: FONT_BOLD , "</header>" => Colors :: RESET , "<highlight>" => Colors :: COLOR_FGL_YELLOW . Colors :: FONT_BOLD , "</highlight>" => Colors :: RESET , "<warn>" => Colors :: COLOR_FG_RED , "</warn>" => Colors :: RESET , "<info>" => Colors :: COLOR_FGL_BLUE , "</info>" => Colors :: RESET , "<error>" => Colors :: COLOR_BG_RED . Colors :: COLOR_FGL_WHITE , "</error>" => Colors :: RESET ] ; }
very simple color scheme to be used through replaces
1,276
public static function fromURL ( $ url , $ stripHost ) { $ data = parse_url ( $ url ) ; $ parameters = array ( ) ; if ( ! empty ( $ data [ 'query' ] ) ) parse_str ( $ data [ 'query' ] , $ parameters ) ; $ request = new self ( ) ; if ( $ stripHost ) { $ request -> setUrl ( $ data [ 'path' ] ) ; } else { $ request -> setUrl ( $ data [ 'scheme' ] . '://' . $ data [ 'host' ] . ( isset ( $ data [ 'port' ] ) ? ':' . $ data [ 'port' ] : '' ) . $ data [ 'path' ] ) ; } $ request -> setParameters ( $ parameters ) ; return $ request ; }
Return a request based on a simple url .
1,277
public function setUserCallback ( callable $ callback ) { if ( count ( $ this -> usercallback ) > 0 ) throw new InvalidParameter ( "A usercallback was already set. Use addUserCallback to add multiple callbacks" ) ; $ this -> addUserCallback ( 'default' , $ callback ) ; return $ this ; }
To allow lazy loading of the user object set a callback here . Method will be called with request as parameter and only once a script .
1,278
public function addUserCallback ( $ name , callable $ callback ) { if ( isset ( $ this -> usercallback [ $ name ] ) ) throw new InvalidParameter ( "A usercallback with name " . $ name . " is already set. Each callback must have a unique name." ) ; $ this -> usercallback [ $ name ] = $ callback ; return $ this ; }
To allow for multiple authentication methods extra user callbacks can be set . Each callback must have a unique name . This name can be used in getUser to force
1,279
public function parseRoute ( Route $ route ) { if ( preg_match_all ( '#^' . $ route -> getRoute ( ) . '$#' , $ this -> getUrl ( ) , $ matches , PREG_OFFSET_CAPTURE ) ) { $ matches = array_slice ( $ matches , 1 ) ; $ params = array_map ( function ( $ match , $ index ) use ( $ matches ) { if ( isset ( $ matches [ $ index + 1 ] ) && isset ( $ matches [ $ index + 1 ] [ 0 ] ) && is_array ( $ matches [ $ index + 1 ] [ 0 ] ) ) { return trim ( substr ( $ match [ 0 ] [ 0 ] , 0 , $ matches [ $ index + 1 ] [ 0 ] [ 1 ] - $ match [ 0 ] [ 1 ] ) , '/' ) ; } else { return ( isset ( $ match [ 0 ] [ 0 ] ) ? trim ( $ match [ 0 ] [ 0 ] , '/' ) : null ) ; } } , $ matches , array_keys ( $ matches ) ) ; if ( empty ( $ params ) ) { return true ; } else { return $ params ; } } return false ; }
Evaluate a route and return the parameters .
1,280
public static function load ( string $ attributes , array $ keys = [ ] ) : IdentificatorInterface { $ values = explode ( ";" , $ attributes ) ; $ attributes = [ ] ; foreach ( $ keys as $ k => $ key ) { if ( array_key_exists ( $ k , $ values ) ) { $ attributes [ $ key ] = $ values [ $ k ] ; } } return new Identificator ( $ attributes ) ; }
Create Identificator instance from string attributes .
1,281
public function toArray ( ) { return [ 'hard_quota' => $ this -> getHardQuota ( ) , 'soft_quota' => $ this -> getSoftQuota ( ) , 'soft_quota_percent' => $ this -> getSoftQuotaPercent ( ) , 'usage' => $ this -> getUsage ( ) , 'usage_percent' => $ this -> getUsagePercent ( ) , 'remaining_soft_quota' => $ this -> getRemainingSoftQuota ( ) , 'remaining_soft_quota_percent' => $ this -> getRemainingSoftQuotaPercent ( ) , 'remaining_hard_quota' => $ this -> getRemainingHardQuota ( ) , 'remaining_hard_quota_percent' => $ this -> getRemainingHardQuotaPercent ( ) , ] ; }
Return array representation .
1,282
public function getUsage ( ) { if ( $ this -> usage === null ) { $ calculator = new SizeCalculator ( ) ; $ calculatedSize = $ calculator -> calculate ( $ this -> volume , $ this -> volume -> findRootFolder ( ) ) ; $ this -> usage = $ calculatedSize -> getSize ( ) ; } return $ this -> usage ; }
Return Usage in bytes .
1,283
public static function Apco13 ( $ utc1 , $ utc2 , $ dut1 , $ elong , $ phi , $ hm , $ xp , $ yp , $ phpa , $ tc , $ rh , $ wl , iauASTROM & $ astrom , & $ eo ) { $ j ; $ tai1 ; $ tai2 ; $ tt1 ; $ tt2 ; $ ut11 ; $ ut12 ; $ ehpv = [ ] ; $ ebpv = [ ] ; $ r = [ ] ; $ x ; $ y ; $ s ; $ theta ; $ sp ; $ refa ; $ refb ; $ j = IAU :: Utctai ( $ utc1 , $ utc2 , $ tai1 , $ tai2 ) ; if ( $ j < 0 ) return - 1 ; $ j = IAU :: Taitt ( $ tai1 , $ tai2 , $ tt1 , $ tt2 ) ; $ j = IAU :: Utcut1 ( $ utc1 , $ utc2 , $ dut1 , $ ut11 , $ ut12 ) ; if ( $ j < 0 ) return - 1 ; IAU :: Epv00 ( $ tt1 , $ tt2 , $ ehpv , $ ebpv ) ; IAU :: Pnm06a ( $ tt1 , $ tt2 , $ r ) ; IAU :: Bpn2xy ( $ r , $ x , $ y ) ; $ s = IAU :: S06 ( $ tt1 , $ tt2 , $ x , $ y ) ; $ theta = IAU :: Era00 ( $ ut11 , $ ut12 ) ; $ sp = IAU :: Sp00 ( $ tt1 , $ tt2 ) ; IAU :: Refco ( $ phpa , $ tc , $ rh , $ wl , $ refa , $ refb ) ; IAU :: Apco ( $ tt1 , $ tt2 , $ ebpv , $ ehpv [ 0 ] , $ x , $ y , $ s , $ theta , $ elong , $ phi , $ hm , $ xp , $ yp , $ sp , $ refa , $ refb , $ astrom ) ; $ eo = IAU :: Eors ( $ r , $ s ) ; return $ j ; }
- - - - - - - - - - i a u A p c o 1 3 - - - - - - - - - -
1,284
public function setAttribute ( string $ name , $ value ) { if ( ! $ this -> _supportedAttributes -> has ( $ name ) ) { throw new ArgumentException ( 'name' , $ name , 'Can not set the DB driver "' . $ this -> _type . '" not supports a attribute with this name!' ) ; } if ( ! $ this -> _supportedAttributes -> get ( $ name ) -> validateValue ( $ value ) ) { throw new ArgumentException ( 'value' , $ value , 'Can not set the DB driver "' . $ this -> _type . '" attribute "' . $ name . '" value, because the value is invalid!' ) ; } $ this -> _attributes [ $ name ] = $ value ; return $ this ; }
Sets the value of a driver specific Attribute .
1,285
public function getAttribute ( string $ name , $ defaultValue = false ) { if ( ! $ this -> hasAttribute ( $ name ) ) { return $ defaultValue ; } return $ this -> _attributes [ $ name ] ; }
Gets the value of a driver specific Attribute .
1,286
public function getAvatarUrl ( $ size = 200 ) { $ protocol = \ Yii :: $ app -> request -> isSecureConnection ? 'https' : 'http' ; return $ protocol . '://gravatar.com/avatar/' . $ this -> gravatar_id . '?s=' . $ size ; }
Returns avatar url or null if avatar is not set .
1,287
protected function addHost ( $ type , array $ options , $ master_as_slave = true ) { $ this -> hosts [ $ type ] [ ] = $ options ; if ( $ type == \ Octris \ Db :: DB_MASTER && $ master_as_slave ) { $ this -> hosts [ \ Octris \ Db :: DB_SLAVE ] [ ] = $ options ; } }
Add host configuration of specified type .
1,288
public function getConnection ( $ type = \ Octris \ Db :: DB_MASTER ) { if ( $ type != \ Octris \ Db :: DB_MASTER && $ type != \ Octris \ Db :: DB_SLAVE ) { throw new \ Exception ( 'unknown connection type "' . $ type . '"' ) ; } else { if ( ! ( $ cn = array_shift ( $ this -> pool [ $ type ] ) ) ) { if ( count ( $ this -> hosts [ $ type ] ) == 0 ) { throw new \ Exception ( sprintf ( 'No database configuration available for connection to a "%s" host.' , $ type ) ) ; } shuffle ( $ this -> hosts [ $ type ] ) ; $ cn = $ this -> createConnection ( $ this -> hosts [ $ type ] [ 0 ] ) ; if ( ! ( $ cn instanceof \ Octris \ Db \ Device \ ConnectionInterface ) ) { throw new \ Exception ( 'connection handler needs to implement interface "\Octris\Db\Device\ConnectionInterface"' ) ; } } $ this -> connections [ spl_object_hash ( $ cn ) ] = $ type ; } return $ cn ; }
Return a database connection of specified type .
1,289
public function release ( \ Octris \ Db \ Device \ ConnectionInterface $ cn ) { $ hash = spl_object_hash ( $ cn ) ; if ( ! isset ( $ this -> connections [ $ hash ] ) ) { throw new \ Exception ( 'Connection is not handled by this device' ) ; } array_push ( $ this -> pool [ $ this -> connections [ $ hash ] ] , $ cn ) ; unset ( $ this -> connections [ $ hash ] ) ; }
Release a connection push it back into the pool .
1,290
public function menuAction ( ) { $ params = $ this -> params ( ) ; $ navigation = $ this -> getServiceLocator ( ) -> get ( 'Grid\Menu\Model\Menu\Model' ) -> findNavigation ( $ params -> fromRoute ( 'id' ) ) ; $ view = new ViewModel ( array ( 'navigation' => $ navigation , ) ) ; $ this -> getResponse ( ) -> getHeaders ( ) -> addHeaderLine ( 'Content-Type' , 'application/xml' ) ; return $ view -> setTerminal ( true ) ; }
Render a standalone sitemap for a menu
1,291
public function indexAction ( ) { $ navigation = $ this -> getServiceLocator ( ) -> get ( 'Grid\Menu\Model\Menu\Model' ) -> findNavigation ( ) ; $ view = new ViewModel ( array ( 'navigation' => $ navigation , ) ) ; $ this -> getResponse ( ) -> getHeaders ( ) -> addHeaderLine ( 'Content-Type' , 'application/xml' ) ; return $ view -> setTerminal ( true ) ; }
Render a whole sitemap
1,292
public static function format ( $ date = null , $ includeTime = false ) { $ date = new DateTime ( $ date ) ; if ( ! $ includeTime ) { return $ date -> format ( config ( 'settings.dateFormat' ) ) ; } return $ date -> format ( config ( 'settings.dateFormat' ) . ' h:i:s A' ) ; }
Converts a stored date to the user formatted date .
1,293
public static function unformat ( $ userDate = null ) { if ( $ userDate ) { $ date = DateTime :: createFromFormat ( config ( 'settings.dateFormat' ) , $ userDate ) ; return $ date -> format ( 'Y-m-d' ) ; } }
Converts a user submitted date back to standard yyyy - mm - dd format .
1,294
public function generate ( ) : string { $ setID = ( string ) $ this -> attributes [ 'data-set-id' ] ; $ getState = $ this -> vHandler -> get -> get ( $ setID . '_state' , Variables :: TYPE_INT ) == 1 ; $ postState = $ this -> vHandler -> post -> get ( $ setID . '_state' , Variables :: TYPE_INT ) == 1 ; $ expanded = $ getState || $ postState ; $ this -> attributes [ 'class' ] .= $ expanded === true ? ' expanded' : '' ; $ title = [ ] ; $ title [ ] = Tags :: span ( $ this -> name , [ 'class' => 'name' ] ) ; $ title [ ] = Tags :: span ( '' , [ 'class' => 'expand' , 'title' => $ this -> getConstant ( 'TXT_PANEL_DATA_FORM_SET_EXPAND' ) ] ) ; $ title [ ] = Tags :: span ( '' , [ 'class' => 'collapse' , 'title' => $ this -> getConstant ( 'TXT_PANEL_DATA_FORM_SET_COLLAPSE' ) ] ) ; $ title [ ] = Controlls \ Text :: inputHidden ( $ setID . '_state' , ( int ) $ expanded , [ 'method-get' => true , 'id' => '' ] ) ; $ elements = [ ] ; foreach ( $ this -> elements as $ element ) { $ elements [ ] = $ element -> generate ( ) ; } $ set = [ ] ; $ set [ ] = Tags :: div ( $ title , [ 'class' => 'title cf' ] ) ; $ set [ ] = Tags :: div ( $ elements , [ 'class' => 'content border-radius-5' ] ) ; return Tags :: div ( $ set , $ this -> attributes ) ; }
Generates from set and returns it
1,295
public function setModel ( array $ data = [ ] , $ isNew = true ) { $ this -> data = $ data ; $ this -> validator = new \ Illuminate \ Validation \ Validator ( $ this -> translator , $ this -> data , $ this -> getRules ( $ isNew ) , $ this -> getMessages ( ) ) ; $ this -> validator -> setPresenceVerifier ( $ this -> presenceVerifier ) ; $ this -> sometimes ( $ this -> validator , $ isNew ) ; return $ this ; }
Sets current model .
1,296
public function passes ( ) { if ( ! ( $ this -> validator instanceof \ Illuminate \ Validation \ Validator ) ) { throw new LogicException ( 'No model was set. Nothing to validate.' ) ; } return $ this -> getValidator ( ) -> passes ( ) ; }
Returns true if data model passes validation .
1,297
public function fails ( ) { if ( ! ( $ this -> validator instanceof \ Illuminate \ Validation \ Validator ) ) { throw new LogicException ( 'No model was set. Nothing to validate.' ) ; } return $ this -> getValidator ( ) -> fails ( ) ; }
Returns true if data model fails validation .
1,298
public static function Create ( ? int $ hour = null , ? int $ minute = null , ? int $ second = null ) : Time { return new Time ( $ hour , $ minute , $ second ) ; }
Static way to create a new Time instance .
1,299
protected function hasKey ( $ key ) { return ( $ this -> mode == self :: MODE_INDEXED && $ key == '' ) || \ array_key_exists ( $ key , $ this -> params ) ; }
Helper function - test for existence of key in given parameters .