public function load()
    {
        // Check for existence only once and save the result
        $exists = is_file($this->file);

        if ($this->autoCreate == false && !$exists) {
            throw new RuntimeException('File does not exist');
        } else if ($this->autoCreate == true && !$exists) {
            // Create new empty file
            touch($this->file);

            $this->loaded = true;
            // There's no need to fetch content from the empty file
            return array();
        }

        $content = file_get_contents($this->file);
        $content = $this->serializer->unserialize($content);

        if (!$content) {
            $content = array();
        }

        $this->content = $content;
        $this->loaded = true;
    }
public function load()
    {
        // Check for existence only once and save the result
        $exists = is_file($this->file);

        if ($this->autoCreate == false && !$exists) {
            throw new RuntimeException('File does not exist');
        } else if ($this->autoCreate == true && !$exists) {
            // Create new empty file
            touch($this->file);

            $this->loaded = true;
            // There's no need to fetch content from the empty file
            return array();
        }

        $content = file_get_contents($this->file);
        $content = $this->serializer->unserialize($content);

        if (!$content) {
            $content = array();
        }

        $this->content = $content;
        $this->loaded = true;
    }
public function load ( ) { // Check for existence only once and save the result $ exists = is_file ( $ this -> file ) ; if ( $ this -> autoCreate == false && ! $ exists ) { throw new RuntimeException ( 'File does not exist' ) ; } else if ( $ this -> autoCreate == true && ! $ exists ) { // Create new empty file touch ( $ this -> file ) ; $ this -> loaded = true ; // There's no need to fetch content from the empty file return array ( ) ; } $ content = file_get_contents ( $ this -> file ) ; $ content = $ this -> serializer -> unserialize ( $ content ) ; if ( ! $ content ) { $ content = array ( ) ; } $ this -> content = $ content ; $ this -> loaded = true ; }
Loads content from a file

@throws \RuntimeException When $autoCreate set to false and file doesn't exist
@return array
Loads content from a file