ImageFile
class ImageFile extends File (View source)
Traits
Properties
| static protected array | $macros | The registered string macros.  | 
                from Macroable | 
| protected array | $allowedMimetypes | The MIME types that the given file should match. This array may also contain file extensions.  | 
                from File | 
| protected array | $allowedExtensions | The extensions that the given file should match.  | 
                from File | 
| protected null|int | $minimumFileSize | The minimum size in kilobytes that the file can be.  | 
                from File | 
| protected null|int | $maximumFileSize | The maximum size in kilobytes that the file can be.  | 
                from File | 
| protected array | $customRules | An array of custom rules that will be merged into the validation rules.  | 
                from File | 
| protected array | $messages | The error message after validation, if any.  | 
                from File | 
| protected array | $data | The data under validation.  | 
                from File | 
| protected Validator | $validator | The validator performing the validation.  | 
                from File | 
| static string|array|callable|null | $defaultCallback | The callback that will generate the "default" version of the file rule.  | 
                from File | 
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Set the default callback to be used for determining the file default rules.
Limit the uploaded file to the given MIME types or file extensions.
Limit the uploaded file to the given file extensions.
Indicate that the uploaded file should be exactly a certain size in kilobytes.
Indicate that the uploaded file should be between a minimum and maximum size in kilobytes.
Indicate that the uploaded file should be no less than the given number of kilobytes.
Indicate that the uploaded file should be no more than the given number of kilobytes.
Convert a potentially human-friendly file size to kilobytes.
Specify additional validation rules that should be merged with the default rules during validation.
Build the array of underlying validation rules based on the current state.
Separate the given mimetypes from extensions and return an array of correct rules to validate against.
Create a new image file rule instance.
Details
        
                            $this|TWhenReturnType
    when($value = null, callable|null $callback = null, callable|null $default = null)
        
    
    Apply the callback if the given "value" is (or resolves to) truthy.
        
                            $this|TUnlessReturnType
    unless($value = null, callable|null $callback = null, callable|null $default = null)
        
    
    Apply the callback if the given "value" is (or resolves to) falsy.
        
                static            void
    macro(string $name, object|callable $macro)
        
    
    Register a custom macro.
        
                static            void
    mixin(object $mixin, bool $replace = true)
        
    
    Mix another object into the class.
        
                static            bool
    hasMacro(string $name)
        
    
    Checks if macro is registered.
        
                static            void
    flushMacros()
        
    
    Flush the existing macros.
        
                static            mixed
    __callStatic(string $method, array $parameters)
        
    
    Dynamically handle calls to the class.
        
                            mixed
    __call(string $method, array $parameters)
        
    
    Dynamically handle calls to the class.
        in 
File at line 91
                static            File|void
    defaults(File|callable|null $callback = null)
        
    
    Set the default callback to be used for determining the file default rules.
If no arguments are passed, the default file rule configuration will be returned.
        in 
File at line 109
                static            File
    default()
        
    
    Get the default configuration of the file rule.
        in 
File at line 123
                static            ImageFile
    image()
        
    
    Limit the uploaded file to only image types.
        in 
File at line 134
                static            File
    types(string|array<int,string> $mimetypes)
        
    
    Limit the uploaded file to the given MIME types or file extensions.
        in 
File at line 145
                            $this
    extensions(string|array<int,string> $extensions)
        
    
    Limit the uploaded file to the given file extensions.
        in 
File at line 158
                            $this
    size(string|int $size)
        
    
    Indicate that the uploaded file should be exactly a certain size in kilobytes.
        in 
File at line 173
                            $this
    between(string|int $minSize, string|int $maxSize)
        
    
    Indicate that the uploaded file should be between a minimum and maximum size in kilobytes.
        in 
File at line 187
                            $this
    min(string|int $size)
        
    
    Indicate that the uploaded file should be no less than the given number of kilobytes.
        in 
File at line 200
                            $this
    max(string|int $size)
        
    
    Indicate that the uploaded file should be no more than the given number of kilobytes.
        in 
File at line 213
                    protected        mixed
    toKilobytes(string|int $size)
        
    
    Convert a potentially human-friendly file size to kilobytes.
        in 
File at line 236
                            $this
    rules(string|array $rules)
        
    
    Specify additional validation rules that should be merged with the default rules during validation.
        in 
File at line 250
                            bool
    passes(string $attribute, mixed $value)
        
    
    Determine if the validation rule passes.
        in 
File at line 273
                    protected        array
    buildValidationRules()
        
    
    Build the array of underlying validation rules based on the current state.
        in 
File at line 299
                    protected        array
    buildMimetypes()
        
    
    Separate the given mimetypes from extensions and return an array of correct rules to validate against.
        in 
File at line 331
                    protected        bool
    fail(array|string $messages)
        
    
    Adds the given failures, and return false.
        in 
File at line 347
                            string|array
    message()
        
    
    Get the validation error message.
        in 
File at line 358
                            $this
    setValidator(Validator $validator)
        
    
    Set the current validator.
        in 
File at line 371
                            $this
    setData(array $data)
        
    
    Set the current data under validation.
        
                            void
    __construct()
        
    
    Create a new image file rule instance.
        
                            
    dimensions(Dimensions $dimensions)
        
    
    The dimension constraints for the uploaded file.