PHP Class Captioning\File

Inheritance: implements captioning\FileInterface
Show file Open project: captioning/captioning Class Usage Examples

Protected Properties

Property Type Description
$cues array
$encoding string
$fileContent string
$filename string
$lineEnding string
$stats array
$useIconv boolean

Public Methods

Method Description
__construct ( null $_filename = null, null $_encoding = null, boolean | false $_useIconv = false ) File constructor.
addCue ( mixed $_mixed, string $_start = null, string $_stop = null ) : File Add a cue
build ( )
changeFPS ( float $_old_fps, float $_new_fps ) : File Converts timecodes based on the specified FPS ratio
convertTo ( string $_output_format ) : mixed
getCue ( integer $_index ) : Cue | null
getCueFromStart ( $_start )
getCues ( ) : array
getCuesCount ( ) : integer
getEncoding ( ) : string
getExpectedCueClass ( captioning\FileInterface $_file, boolean | true $_full_namespace = true ) : string
getFileContent ( ) : string
getFilename ( ) : string
getFirstCue ( ) : Cue | null
getFormat ( captioning\FileInterface $_file ) : mixed
getLastCue ( ) : Cue | null
getStats ( ) Computes reading speed statistics
getUseIconv ( ) : boolean | false
loadFromFile ( null $_filename = null )
loadFromString ( string $_str )
merge ( captioning\FileInterface $_file )
removeCue ( integer $_index ) : File Removes a cue
save ( string $filename = null, boolean $writeBOM = false ) Saves the file
search ( string $_word, boolean $_case_sensitive = false, boolean $_strict = false ) : array Searches a word/expression and returns ids of the matched entries
setEncoding ( string $_encoding )
setFilename ( string $_filename )
setLineEnding ( string $_lineEnding )
setUseIconv ( boolean $_useIconv )
shift ( integer $_time, integer $_startIndex = null, integer $_endIndex = null ) Shifts a range of subtitles a specified amount of time.
sortCues ( ) Sorts cues
sync ( integer $_startIndex, integer $_startTime, integer $_endIndex, integer $_endTime, boolean $_syncLast = true ) : boolean Auto syncs a range of subtitles given their first and last correct times.

Protected Methods

Method Description
encode ( ) Encode file content
getFileContentAsArray ( ) : array
getNextValueFromArray ( array &$array ) : mixed

Method Details

__construct() public method

File constructor.
public __construct ( null $_filename = null, null $_encoding = null, boolean | false $_useIconv = false )
$_filename null
$_encoding null
$_useIconv boolean | false

addCue() public method

Add a cue
public addCue ( mixed $_mixed, string $_start = null, string $_stop = null ) : File
$_mixed mixed An cue instance or a string representing the text
$_start string A timecode
$_stop string A timecode
return File

build() public method

public build ( )

changeFPS() public method

Converts timecodes based on the specified FPS ratio
public changeFPS ( float $_old_fps, float $_new_fps ) : File
$_old_fps float
$_new_fps float
return File

convertTo() public method

public convertTo ( string $_output_format ) : mixed
$_output_format string
return mixed

encode() protected method

Encode file content
protected encode ( )

getCue() public method

public getCue ( integer $_index ) : Cue | null
$_index integer
return Cue | null

getCueFromStart() public method

public getCueFromStart ( $_start )

getCues() public method

public getCues ( ) : array
return array

getCuesCount() public method

public getCuesCount ( ) : integer
return integer

getEncoding() public method

public getEncoding ( ) : string
return string

getExpectedCueClass() public static method

public static getExpectedCueClass ( captioning\FileInterface $_file, boolean | true $_full_namespace = true ) : string
$_file captioning\FileInterface
$_full_namespace boolean | true
return string

getFileContent() public method

public getFileContent ( ) : string
return string

getFileContentAsArray() protected method

protected getFileContentAsArray ( ) : array
return array

getFilename() public method

public getFilename ( ) : string
return string

getFirstCue() public method

public getFirstCue ( ) : Cue | null
return Cue | null

getFormat() public static method

public static getFormat ( captioning\FileInterface $_file ) : mixed
$_file captioning\FileInterface
return mixed

getLastCue() public method

public getLastCue ( ) : Cue | null
return Cue | null

getNextValueFromArray() protected method

protected getNextValueFromArray ( array &$array ) : mixed
$array array
return mixed

getStats() public method

Computes reading speed statistics
public getStats ( )

getUseIconv() public method

public getUseIconv ( ) : boolean | false
return boolean | false

loadFromFile() public method

public loadFromFile ( null $_filename = null )
$_filename null

loadFromString() public method

public loadFromString ( string $_str )
$_str string

merge() public method

public merge ( captioning\FileInterface $_file )
$_file captioning\FileInterface

removeCue() public method

Removes a cue
public removeCue ( integer $_index ) : File
$_index integer
return File

save() public method

Saves the file
public save ( string $filename = null, boolean $writeBOM = false )
$filename string
$writeBOM boolean

setEncoding() public method

public setEncoding ( string $_encoding )
$_encoding string

setFilename() public method

public setFilename ( string $_filename )
$_filename string The filename

setLineEnding() public method

public setLineEnding ( string $_lineEnding )
$_lineEnding string

setUseIconv() public method

public setUseIconv ( boolean $_useIconv )
$_useIconv boolean

shift() public method

Shifts a range of subtitles a specified amount of time.
public shift ( integer $_time, integer $_startIndex = null, integer $_endIndex = null )
$_time integer The time to use (ms), which can be positive or negative.
$_startIndex integer The subtitle index the range begins with.
$_endIndex integer The subtitle index the range ends with.

sortCues() public method

Sorts cues
public sortCues ( )

sync() public method

The subtitles are first shifted to the first subtitle's correct time, and then proportionally adjusted using the last subtitle's correct time. Based on gnome-subtitles (https://git.gnome.org/browse/gnome-subtitles/)
public sync ( integer $_startIndex, integer $_startTime, integer $_endIndex, integer $_endTime, boolean $_syncLast = true ) : boolean
$_startIndex integer The subtitle index to start the adjustment with.
$_startTime integer The correct start time for the first subtitle.
$_endIndex integer The subtitle index to end the adjustment with.
$_endTime integer The correct start time for the last subtitle.
$_syncLast boolean Whether to sync the last subtitle.
return boolean Whether the subtitles could be adjusted

Property Details

$cues protected property

protected array $cues
return array

$encoding protected property

protected string $encoding
return string

$fileContent protected property

protected string $fileContent
return string

$filename protected property

protected string $filename
return string

$lineEnding protected property

protected string $lineEnding
return string

$stats protected property

protected array $stats
return array

$useIconv protected property

protected bool $useIconv
return boolean