Свойство обьекта не видно в методах

Браузер говорит

Warning: file_get_contents(): Filename cannot be empty in C:\Users\Admin\Downloads\OSPanel\domains\localhost\classes\class\file.php on line 14
Evrithing is OK!

index.php

<?php
require_once 'class/file.php';
ini_set('display_errors',1);
$file = new File(__DIR__.'/text.txt', 'some content');
$file->getContents();

class.php

<?php

class File {
    public $filename;
    public $content;

    public function __construct($filename,$content) {
        $this->filename = $filename;
        $this->content = $content;
        if (is_writable($filename)) file_put_contents($filename, $content, FILE_APPEND);
        else die('Cant open to write file');  
    }
    public function getContents(){
       file_get_contents($this->filename = $filename);
    }
    public function __destruct() {
        echo 'Evrithing is OK!';
       echo $this->filename = $filename;
    }
}

Почему то функия getGontents не видит значение свойства $filename


Ответы (0 шт):