PHP Class Flitch\File\File

Inheritance: extends SplDoublyLinkedLis\SplDoublyLinkedList, implements SeekableIterato\SeekableIterator
Show file Open project: dasprid/flitch Class Usage Examples

Protected Properties

Property Type Description
$encoding string Encoding of the file.
$filename string Filename of the represented file.
$lines array Lines of the file.
$source string Source code of the represented file.
$violations array Violations in this file.

Public Methods

Method Description
__construct ( string $filename, string $source, string $encoding = 'utf-8' ) : void Create a new file representation.
addViolation ( Violation $violation ) : void Add a violation to the file.
getEncoding ( ) : string Get encoding of the file.
getFilename ( ) : string Get the filename of the represented file.
getLines ( ) : array Get all lines of the source code as array.
getSource ( ) : string Get the source code of the represented file.
getViolations ( ) : array Get all produced violations.
seek ( integer $position ) : void seek(): defined by SeekableIterator interface.
seekNextLine ( ) : boolean Seek to the next line.
seekTokenType ( mixed $type, boolean $backwards = false, mixed $stopper = null ) : boolean Seek to a specific token type.

Method Details

__construct() public method

Create a new file representation.
public __construct ( string $filename, string $source, string $encoding = 'utf-8' ) : void
$filename string
$source string
$encoding string
return void

addViolation() public method

Add a violation to the file.
public addViolation ( Violation $violation ) : void
$violation Violation
return void

getEncoding() public method

Get encoding of the file.
public getEncoding ( ) : string
return string

getFilename() public method

Get the filename of the represented file.
public getFilename ( ) : string
return string

getLines() public method

Get all lines of the source code as array.
public getLines ( ) : array
return array

getSource() public method

Get the source code of the represented file.
public getSource ( ) : string
return string

getViolations() public method

Violations will be sorted by line/column before being returned.
public getViolations ( ) : array
return array

seek() public method

seek(): defined by SeekableIterator interface.
See also: SeekableIterator::seek()
public seek ( integer $position ) : void
$position integer
return void

seekNextLine() public method

Seek to the next line.
public seekNextLine ( ) : boolean
return boolean

seekTokenType() public method

Returns true on success and false if the token can not be found. Seeking starts from current element. If the current token matches the given type, the position is not changed. In case a stopper is supplied, the seeking will stop at the given token.
public seekTokenType ( mixed $type, boolean $backwards = false, mixed $stopper = null ) : boolean
$type mixed
$backwards boolean
$stopper mixed
return boolean

Property Details

$encoding protected property

Encoding of the file.
protected string $encoding
return string

$filename protected property

Filename of the represented file.
protected string $filename
return string

$lines protected property

Lines of the file.
protected array $lines
return array

$source protected property

Source code of the represented file.
protected string $source
return string

$violations protected property

Violations in this file.
protected array $violations
return array