Flitch\File\File::__construct PHP Method

__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
    public function __construct($filename, $source, $encoding = 'utf-8')
    {
        $this->filename = $filename;
        $this->source = $source;
        $this->encoding = $encoding;
        // Split source into line arrays, containing both content and ending.
        preg_match_all('((?<content>.*?)(?<ending>\\n|\\r\\n?|$))', $source, $matches, PREG_SET_ORDER);
        foreach ($matches as $index => $line) {
            $this->lines[$index + 1] = array('content' => $line['content'], 'ending' => $line['ending']);
        }
    }