public function findById($id)
    {
        if(!file_exists($path = $this->getPathForDocument($id))) {
            return false;
        }

        $fp       = fopen($path, 'r');
        $contents = fread($fp, filesize($path));
        fclose($fp);

        $data = $this->formatter->decode($contents);

        if($data === null) {
            return false;
        }

        $ext = $this->formatter->getFileExtension();

        $doc = new $this->documentClass((array) $data);
        $doc->setId($this->getIdFromPath($path, $ext));

        return $doc;
    }
public function findById($id)
    {
        if(!file_exists($path = $this->getPathForDocument($id))) {
            return false;
        }

        $fp       = fopen($path, 'r');
        $contents = fread($fp, filesize($path));
        fclose($fp);

        $data = $this->formatter->decode($contents);

        if($data === null) {
            return false;
        }

        $ext = $this->formatter->getFileExtension();

        $doc = new $this->documentClass((array) $data);
        $doc->setId($this->getIdFromPath($path, $ext));

        return $doc;
    }
public function findById ( $ id ) { if ( ! file_exists ( $ path = $ this -> getPathForDocument ( $ id ) ) ) { return false ; } $ fp = fopen ( $ path , 'r' ) ; $ contents = fread ( $ fp , filesize ( $ path ) ) ; fclose ( $ fp ) ; $ data = $ this -> formatter -> decode ( $ contents ) ; if ( $ data === null ) { return false ; } $ ext = $ this -> formatter -> getFileExtension ( ) ; $ doc = new $ this -> documentClass ( ( array ) $ data ) ; $ doc -> setId ( $ this -> getIdFromPath ( $ path , $ ext ) ) ; return $ doc ; }
Returns a single document based on it's ID

@param  string $id The ID of the document to find

@return Document|boolean  The document if it exists, false if not.
Returns a single document based on it s ID