PHP Class app\models\File

Inheritance: extends NeoEloquent
Show file Open project: phanan/koel Class Usage Examples

Protected Properties

Property Type Description
$getID3 getID\getID3 The getID3 object, for ID3 tag reading.
$hash string This value is unique, and can be used to query a Song record.
$mtime integer The file's last modified time.
$path string The file's path.
$song Song The song model that's associated with this file.
$splFileInfo SplFileInf\SplFileInfo The SplFileInfo object of the file.
$syncError string The last parsing error text, if any.

Public Methods

Method Description
__construct ( string | SplFileInf\SplFileInfo $path, getID\getID3 $getID3 = null ) Construct our File object.
getGetID3 ( ) : getID\getID3
getHash ( string $path ) : string Get a unique hash from a file path.
getInfo ( ) : array | void Get all applicable ID3 info from the file.
getPath ( ) : string
getSyncError ( ) : syncError Get the last parsing error's text.
isChanged ( ) : boolean Determine if the file is changed (its Song record is found, but the timestamp is different).
isNew ( ) : boolean Determine if the file is new (its Song record can't be found in the database).
isNewOrChanged ( ) : boolean Determine if the file is new or changed.
setGetID3 ( getID\getID3 $getID3 = null )
sync ( array $tags, boolean $force = false ) : boolean | Song Sync the song with all available media info against the database.

Private Methods

Method Description
getCoverFileUnderSameDirectory ( ) : string | false Issue #380.

Method Details

__construct() public method

Upon construction, we'll set the path, hash, and associated Song object (if any).
public __construct ( string | SplFileInf\SplFileInfo $path, getID\getID3 $getID3 = null )
$path string | SplFileInf\SplFileInfo Either the file's path, or a SplFileInfo object
$getID3 getID\getID3 A getID3 object for DI (and better performance)

getGetID3() public method

public getGetID3 ( ) : getID\getID3
return getID\getID3

getHash() public static method

Get a unique hash from a file path.
public static getHash ( string $path ) : string
$path string
return string

getInfo() public method

Get all applicable ID3 info from the file.
public getInfo ( ) : array | void
return array | void

getPath() public method

public getPath ( ) : string
return string

getSyncError() public method

Get the last parsing error's text.
public getSyncError ( ) : syncError
return syncError

isChanged() public method

Determine if the file is changed (its Song record is found, but the timestamp is different).
public isChanged ( ) : boolean
return boolean

isNew() public method

Determine if the file is new (its Song record can't be found in the database).
public isNew ( ) : boolean
return boolean

isNewOrChanged() public method

Determine if the file is new or changed.
public isNewOrChanged ( ) : boolean
return boolean

setGetID3() public method

public setGetID3 ( getID\getID3 $getID3 = null )
$getID3 getID\getID3

sync() public method

Sync the song with all available media info against the database.
public sync ( array $tags, boolean $force = false ) : boolean | Song
$tags array The (selective) tags to sync (if the song exists)
$force boolean Whether to force syncing, even if the file is unchanged
return boolean | Song A Song object on success, true if file exists but is unmodified, or false on an error.

Property Details

$getID3 protected property

The getID3 object, for ID3 tag reading.
protected getID3,getID $getID3
return getID\getID3

$hash protected property

This value is unique, and can be used to query a Song record.
protected string $hash
return string

$mtime protected property

The file's last modified time.
protected int $mtime
return integer

$path protected property

The file's path.
protected string $path
return string

$song protected property

The song model that's associated with this file.
protected Song,app\models $song
return Song

$splFileInfo protected property

The SplFileInfo object of the file.
protected SplFileInfo,SplFileInf $splFileInfo
return SplFileInf\SplFileInfo

$syncError protected property

The last parsing error text, if any.
protected string $syncError
return string