Skip to content

Commit 150b536

Browse files
Add BaseException
1 parent e745d80 commit 150b536

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

examples/example2.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
require_once('../vendor/autoload.php');
3+
4+
use \Howtomakeaturn\PDFInfo\PDFInfo;
5+
6+
$whoops = new \Whoops\Run;
7+
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
8+
$whoops->register();
9+
10+
$pdf = new PDFInfo('files/not-exist.pdf');
11+
12+
echo $pdf->title;
13+
echo '<hr />';
14+
echo $pdf->author;
15+
echo '<hr />';
16+
echo $pdf->creator;
17+
echo '<hr />';
18+
echo $pdf->producer;
19+
echo '<hr />';
20+
echo $pdf->creationDate;
21+
echo '<hr />';
22+
echo $pdf->modDate;
23+
echo '<hr />';
24+
echo $pdf->tagged;
25+
echo '<hr />';
26+
echo $pdf->form;
27+
echo '<hr />';
28+
echo $pdf->pages;
29+
echo '<hr />';
30+
echo $pdf->encrypted;
31+
echo '<hr />';
32+
echo $pdf->pageSize;
33+
echo '<hr />';
34+
echo $pdf->fileSize;
35+
echo '<hr />';
36+
echo $pdf->optimized;
37+
echo '<hr />';
38+
echo $pdf->PDFVersion;
39+
echo '<hr />';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
namespace Howtomakeaturn\PDFInfo\Exceptions;
3+
4+
use \Exception;
5+
6+
class BaseException extends Exception{};

src/Howtomakeaturn/PDFInfo/PDFInfo.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ private function loadOutput()
4242
$file = escapeshellarg($this->file);
4343
// Parse entire output
4444
// Surround with double quotes if file name has spaces
45-
exec("$cmd $file", $output);
45+
exec("$cmd $file", $output, $returnVar);
46+
47+
if ( $returnVar !== 0 ){
48+
throw new Exceptions\BaseException();
49+
}
4650

4751
$this->output = $output;
4852
}

0 commit comments

Comments
 (0)