Oroboros Core
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • None
  • oroboros
    • core
      • abstracts
        • adapters
        • bootstrap
        • controllers
        • libraries
          • auth
          • bootstrap
          • cache
          • codex
          • config
          • container
          • data
          • database
          • dns
          • entity
          • enum
          • error
          • event
          • extension
          • file
          • flags
          • hooks
          • job
          • logger
          • manager
          • message
          • prototype
          • request
          • response
          • routine
          • shell
          • startup
          • stream
          • template
          • uri
          • utility
          • validation
            • workers
          • worker
        • models
        • patterns
          • behavioral
          • creational
        • utilities
          • exception
            • cache
            • container
          • http
        • views
      • interfaces
        • adapters
          • interpreters
          • sdk
        • api
          • adapters
          • bootstrap
          • controllers
          • psr
        • contract
          • adapters
          • bootstrap
          • codex
          • components
          • controllers
          • data
          • entities
          • errors
          • events
          • extensions
          • jobs
          • libraries
            • auth
            • cache
            • config
            • container
            • enum
            • file
            • flags
            • hooks
            • module
            • promise
            • record
            • request
            • response
            • server
            • shutdown
            • site
            • stream
            • template
            • theme
            • uri
          • models
          • patterns
            • behavioral
            • concurrency
            • creational
            • structural
          • routes
          • routines
            • bootload
            • declarative
            • procedural
            • subsystem
          • services
            • consumer
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
            • provider
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
          • utilities
            • datetime
            • exception
              • cache
              • container
            • filebase
            • http
            • math
            • parser
            • regex
            • session
          • views
        • enumerated
          • environment
          • flags
          • http
          • views
        • libraries
          • manager
          • worker
      • libraries
        • api
        • codex
        • container
        • enum
          • http
        • file
        • hooks
        • logger
        • math
        • psr4
        • request
        • response
        • stream
        • uri
      • patterns
        • creational
      • traits
        • adapters
        • bootstrap
        • codex
        • components
        • controllers
        • data
        • entities
        • events
        • extensions
        • jobs
        • libraries
          • container
          • file
          • request
          • response
          • stream
          • uri
        • models
        • modules
        • patterns
          • behavioral
          • concurrency
          • creational
          • structural
        • routes
        • services
        • utilities
          • core
            • api
            • config
            • contract
              • contract
            • enum
            • environment
            • routines
          • datetime
          • error
          • exception
          • filebase
          • hooks
          • html
          • http
          • logic
          • math
          • parsers
          • regex
          • session
        • views
      • utilities
        • exception
          • cache
          • container
        • http
      • views
    • tests
      • patterns
        • creational
      • psr
        • psr7
      • utilities
        • exception
  • PasswordCompat
    • binary
  • PHP

Traits

  • DirectoryTrait
  • FileCollectionTrait
  • FileTrait
  • UploadedFileTrait

Trait FileTrait

Provides a set of methods to represent a file.

Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.

In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.

3rd parties using this package are not expected to follow this approach,

but ALL of our internal class and logic structure does.

Direct Known Users

oroboros\core\abstracts\libraries\file\AbstractFile, oroboros\core\traits\libraries\file\UploadedFileTrait

Indirect Known Users

oroboros\core\libraries\file\File

Namespace: oroboros\core\traits\libraries\file
Package: oroboros\core\file
Category: contract-interfaces
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/contract_interface.md
Located at core/traits/libraries/file/FileTrait.php

Methods summary

public
# __construct( string $file = null, $type = null, $temp_alias = null )

This is a passthru to _initializeFileObject. If no parameters are provided, initialization will need to be manually called.

This is a passthru to _initializeFileObject. If no parameters are provided, initialization will need to be manually called.

Parameters

$file
(optional) if provided, will initialize against this filename. This may be either the the fully qualified path, or a string name of a valid resource that can be created to represent the file.
$type
$temp_alias

Throws

oroboros\core\utilities\exception\RuntimeException
If instantiation cannot complete with the provided parameters.
protected
# _initializeFileObject( string $file = null, string $type = null, string $temp_alias = null )

This method must be called to initialize. The provided constructor will call this method if parameters are passed to it. If the constructor does not recieve parameters, or if another constructor is supplied that overrides this one, this method must be manually called. If no parameters are provided, initialization will need to be manually called.

This method must be called to initialize. The provided constructor will call this method if parameters are passed to it. If the constructor does not recieve parameters, or if another constructor is supplied that overrides this one, this method must be manually called. If no parameters are provided, initialization will need to be manually called.

Parameters

$file
(optional) if provided, will initialize against this filename. This may be either the local file name, or the fully qualified path.
$type
$path (optional) if provided, represents the fully qualified directory path to the file. If not provided, the program will attempt to extract the path from $file.
$temp_alias
(optional) if provided, represents the upload or original name of a temp file. If the file is moved out of the temp directory, it will be named with this value if it is a temp file and no other name is provided.

Throws

oroboros\core\utilities\exception\InvalidArgumentException
if no parameters are supplied.
protected
# _setFileType( string $type = 'bin' )

This may be used to manually select a file type extension internally by classes or traits that use this trait.

This may be used to manually select a file type extension internally by classes or traits that use this trait.

Parameters

$type
(optional) Should be either a valid file extension or mime type. Defaults to binary if not supplied or not valid, to prevent blocking operation.
protected string|null
# _getFileExtension( )

Returns the file extension appropriate for the file. If the file is a temp file that does not have an extension, but the correct extension is known, it will return the correct extension even if the file name does not reflect it. Returns null if the correct extension is not known.

Returns the file extension appropriate for the file. If the file is a temp file that does not have an extension, but the correct extension is known, it will return the correct extension even if the file name does not reflect it. Returns null if the correct extension is not known.

Returns

string|null
protected string
# _getFileMimeType( )

Returns the mime-type of the file, if it is known.

Returns the mime-type of the file, if it is known.

Returns

string
protected string|boolean
# _getFileInfoLink( )

Returns a url pointing to information about the file specification, if one is known, otherwise returns false.

Returns a url pointing to information about the file specification, if one is known, otherwise returns false.

Returns

string|boolean
protected string|boolean
# _getFileAlias( )

Returns the alias name of the file, if one exists, otherwise false.

Returns the alias name of the file, if one exists, otherwise false.

Returns

string|boolean
protected string
# _getFilePath( )

Returns the directory path the file exists in.

Returns the directory path the file exists in.

Returns

string
protected string
# _getFileName( )

Returns the filename.

Returns the filename.

Returns

string
protected
# _getFileFullyQualifiedName( )
protected integer
# _getFileSize( )

Returns the byte count of the filesize.

Returns the byte count of the filesize.

Returns

integer
protected boolean
# _fileExists( )

Returns a boolean determination as to whether the file exists at all.

Returns a boolean determination as to whether the file exists at all.

Returns

boolean
protected boolean
# _fileReadable( )

Returns a boolean determination as to whether the file is readable.

Returns a boolean determination as to whether the file is readable.

Returns

boolean
protected boolean
# _fileWriteable( )

Returns a boolean determination as to whether the file is writeable.

Returns a boolean determination as to whether the file is writeable.

Returns

boolean
protected boolean
# _fileIsTemp( )

Returns a boolean determination as to whether the file is a temp file.

Returns a boolean determination as to whether the file is a temp file.

Returns

boolean
protected boolean
# _fileIsInitialized( )

Returns a boolean determination as to whether the file is initialized. If this is false, no other return method should be trusted to be accurate.

Returns a boolean determination as to whether the file is initialized. If this is false, no other return method should be trusted to be accurate.

Returns

boolean
private
# _setFilePathValue( string $path )

Sets the supplied file directory.

Sets the supplied file directory.

Parameters

$path
$file
private
# _setFileNameValue( string $file )

Sets the supplied file name.

Sets the supplied file name.

Parameters

$file
private
# _setFileTempAliasValue( string $value = null )

Sets the supplied temp alias value, if the file is a temp file.

Sets the supplied temp alias value, if the file is a temp file.

Parameters

$value
private
# _setFileTypeValue( $type = null )

Sets the supplied file type. The file type reflects the actual

Sets the supplied file type. The file type reflects the actual

private
# _setFileExtensionValue( $extension = null )
private
# _setFileExistsValue( )

Sets a boolean flag determining whether the file exists.

Sets a boolean flag determining whether the file exists.

private
# _setFileSizeValue( )

Sets the supplied file size in bytes.

Sets the supplied file size in bytes.

private
# _setFileEncodingValue( $encoding = 'binary' )

Sets the supplied file encoding.

Sets the supplied file encoding.

private
# _setFileReadableValue( )

Sets a boolean determination as to whether the file is readable by the server in the scope of the current runtime.

Sets a boolean determination as to whether the file is readable by the server in the scope of the current runtime.

private
# _setFileWriteableValue( )

Sets a boolean determination as to whether the file is writeable by the server in the scope of the current runtime.

Sets a boolean determination as to whether the file is writeable by the server in the scope of the current runtime.

private resource|false
# _getFileStreamResource( string $mode = 'r' )

Returns a file pointer resource to the file, or false on failure. This method takes the standard fopen valid mode parameters for it's $mode input.

Returns a file pointer resource to the file, or false on failure. This method takes the standard fopen valid mode parameters for it's $mode input.

Parameters

$mode
['r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+', 'x'] Default: 'r'

Returns

resource|false
private
# _moveFileTo( type $new_directory, type $new_filename = null )

Moves the file to a new location. If the same file exists in the new location, it will be replaced.

Moves the file to a new location. If the same file exists in the new location, it will be replaced.

Parameters

$new_directory
The fully qualified path to the new location.
$new_filename
(optional) If provided, will rename the file. If not provided, will retain the existing filename.
private
# _copyFileTo( type $new_directory, type $new_filename = null )

Creates a copy of the file in the specified location. If the same file exists in the new location, it will be replaced.

Creates a copy of the file in the specified location. If the same file exists in the new location, it will be replaced.

Parameters

$new_directory
The fully qualified path to the new location.
$new_filename
(optional) If provided, will rename the file. If not provided, will retain the existing filename.
private
# _deleteFile( )

Deletes the file, if it exists. In most cases, this will render this object unuseable, and it should be unset after this is called.

Deletes the file, if it exists. In most cases, this will render this object unuseable, and it should be unset after this is called.

private
# _truncateFile( )

Truncates the file to zero length, without deleting it.

Truncates the file to zero length, without deleting it.

private
# _touchFile( )

Updates the files 'last modified' property to the current time, as defined by the server.

Updates the files 'last modified' property to the current time, as defined by the server.

private
# _setFileContents( type $content, type $truncate = false, type $append = true )

Sets the file contents.

Sets the file contents.

Parameters

$content
The new content to set in the file.
$truncate
If true, will truncate the file to zero length before setting content. Default false.
$append
If true, the file will be suffixed with the new content. If false, it will be suffixed. Default true
private
# _loadFileCodex( )

Properties summary

private static array $_file_extension_information

Represents a catalog of known file extensions, and can return their extension, mime type, human-readable title, and an information url as to what they do. This is based on a information dictionary provided with the system.

Represents a catalog of known file extensions, and can return their extension, mime type, human-readable title, and an information url as to what they do. This is based on a information dictionary provided with the system.

Todo

Migrate this to the Codex, when the Codex is sufficiently stable to handle static dictionary files. For now this will be compiled directly from the conf dictionary file.
# false
private string $_file_path

Represents the directory path to the file

Represents the directory path to the file

# null
private string $_file_name

Represents the name of the file

Represents the name of the file

# null
private boolean $_file_exists

Represents whether or not the file actually exists.

Represents whether or not the file actually exists.

# false
private integer $_file_size

Represents the size in bytes of the file

Represents the size in bytes of the file

# 0
private string $_file_extension

Represents the file type, as defined by it's suffix. This may not represent the literal file type, if it is accidentally or intentionally misnamed. The default is binary if this cannot be determined.

Represents the file type, as defined by it's suffix. This may not represent the literal file type, if it is accidentally or intentionally misnamed. The default is binary if this cannot be determined.

# null
private string $_file_encoding

Represents the encoding of the file. The default is binary if this cannot be determined.

Represents the encoding of the file. The default is binary if this cannot be determined.

# null
private string $_file_mime

Represents the mime type for http transit. The default is binary if this cannot be determined.

Represents the mime type for http transit. The default is binary if this cannot be determined.

# null
private string|boolean $_file_type_info

Represents a link to external documentation about the file type. The default is false if this cannot be determined.

Represents a link to external documentation about the file type. The default is false if this cannot be determined.

# null
private boolean $_file_readable

Represents whether the file is readable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution.

Represents whether the file is readable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution.

# false
private boolean $_file_writeable

Represents whether the file is writeable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution.

Represents whether the file is writeable by the server or not, within the scope of the current runtime. Note that this may differ between http and cli execution.

# false
private boolean $_file_is_temp

Represents a boolean determination as to whether the file is a temp file or not. This is based off of the system defined temp directory, and will not automatically pick up whether or not the file exists in a custom temp directory not known to the server.

Represents a boolean determination as to whether the file is a temp file or not. This is based off of the system defined temp directory, and will not automatically pick up whether or not the file exists in a custom temp directory not known to the server.

# false
private string|boolean $_file_temp_alias

Represents the desired name of the file, if it was uploaded as a temporary file. The file will be automatically renamed to this name if it is moved from the temp directory, if another name for it is not provided. This is to retain upload names, which do not always correspond to temp save names.

Represents the desired name of the file, if it was uploaded as a temporary file. The file will be automatically renamed to this name if it is moved from the temp directory, if another name for it is not provided. This is to retain upload names, which do not always correspond to temp save names.

# false
private boolean $_file_is_initialized

Determines whether or not the file object wrapper has been initialized.

Determines whether or not the file object wrapper has been initialized.

# false
Oroboros Core API documentation generated by ApiGen