Skip to content

Commit

Permalink
Add BaseException
Browse files Browse the repository at this point in the history
  • Loading branch information
howtomakeaturn committed Mar 22, 2015
1 parent e745d80 commit 150b536
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
39 changes: 39 additions & 0 deletions examples/example2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
require_once('../vendor/autoload.php');

use \Howtomakeaturn\PDFInfo\PDFInfo;

$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();

$pdf = new PDFInfo('files/not-exist.pdf');

echo $pdf->title;
echo '<hr />';
echo $pdf->author;
echo '<hr />';
echo $pdf->creator;
echo '<hr />';
echo $pdf->producer;
echo '<hr />';
echo $pdf->creationDate;
echo '<hr />';
echo $pdf->modDate;
echo '<hr />';
echo $pdf->tagged;
echo '<hr />';
echo $pdf->form;
echo '<hr />';
echo $pdf->pages;
echo '<hr />';
echo $pdf->encrypted;
echo '<hr />';
echo $pdf->pageSize;
echo '<hr />';
echo $pdf->fileSize;
echo '<hr />';
echo $pdf->optimized;
echo '<hr />';
echo $pdf->PDFVersion;
echo '<hr />';
6 changes: 6 additions & 0 deletions src/Howtomakeaturn/PDFInfo/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace Howtomakeaturn\PDFInfo\Exceptions;

use \Exception;

class BaseException extends Exception{};
6 changes: 5 additions & 1 deletion src/Howtomakeaturn/PDFInfo/PDFInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ private function loadOutput()
$file = escapeshellarg($this->file);
// Parse entire output
// Surround with double quotes if file name has spaces
exec("$cmd $file", $output);
exec("$cmd $file", $output, $returnVar);

if ( $returnVar !== 0 ){
throw new Exceptions\BaseException();
}

$this->output = $output;
}
Expand Down

0 comments on commit 150b536

Please sign in to comment.