public function open()
    {
        if (is_file($this->filename)) {
            $fileData = file_get_contents($this->filename);
            if (false === $fileData) {
                throw new IOException('Unable to get the contents of the json file!');
            }
        } else {
            $fileData = null;
            if (!$this->createIfNotExists) {
                throw new FileNotFoundException("The file doesn't exist!");
            }
        }

        if (0 === strlen($fileData)) {
            $this->contents = [];
        } else {
            $this->contents = json_decode($fileData, true);

            if (null === $this->contents) {
                throw new RuntimeException('The format of the JSON file is invalid!');
            }
        }
    }
public function open()
    {
        if (is_file($this->filename)) {
            $fileData = file_get_contents($this->filename);
            if (false === $fileData) {
                throw new IOException('Unable to get the contents of the json file!');
            }
        } else {
            $fileData = null;
            if (!$this->createIfNotExists) {
                throw new FileNotFoundException("The file doesn't exist!");
            }
        }

        if (0 === strlen($fileData)) {
            $this->contents = [];
        } else {
            $this->contents = json_decode($fileData, true);

            if (null === $this->contents) {
                throw new RuntimeException('The format of the JSON file is invalid!');
            }
        }
    }
public function open ( ) { if ( is_file ( $ this -> filename ) ) { $ fileData = file_get_contents ( $ this -> filename ) ; if ( false === $ fileData ) { throw new IOException ( 'Unable to get the contents of the json file!' ) ; } } else { $ fileData = null ; if ( ! $ this -> createIfNotExists ) { throw new FileNotFoundException ( "The file doesn't exist!" ) ; } } if ( 0 === strlen ( $ fileData ) ) { $ this -> contents = [ ] ; } else { $ this -> contents = json_decode ( $ fileData , true ) ; if ( null === $ this -> contents ) { throw new RuntimeException ( 'The format of the JSON file is invalid!' ) ; } } }
Opens the json file.

If the file isn't found, and the {@link createIfNotExists} method is
called with true, then the file will be created when data is written to it.

If the file is empty, then this class will assume the contents to be a
json object.

@return void
Opens the json file .