Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
[ZF2-454][zendframework/zendframework#2403] Logic tweaks
Browse files Browse the repository at this point in the history
- Import Exception namespace, not individual exceptions
  - Update @throws annotation accordingly
- Throw early
  • Loading branch information
weierophinney committed Sep 25, 2012
1 parent 1ed17c3 commit 340bd1d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Writer/FirePhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use FirePHP as FirePHPService;
use Zend\Log\Formatter\FirePhp as FirePhpFormatter;
use Zend\Log\Logger;
use Zend\Log\Exception\RuntimeException;
use Zend\Log\Exception;

/**
* @category Zend
Expand Down Expand Up @@ -84,10 +84,17 @@ protected function doWrite(array $event)
* Gets the FirePhpInterface instance that is used for logging.
*
* @return FirePhp\FirePhpInterface
* @throws Zend\Log\Exception\RuntimeException
* @throws Exception\RuntimeException
*/
public function getFirePhp()
{
if (!$this->firephp instanceof FirePhp\FirePhpInterface
&& !class_exists('FirePHP')
) {
// No FirePHP instance, and no way to create one
throw new Exception\RuntimeException('FirePHP Class not found');
}

// Remember: class names in strings are absolute; thus the class_exists
// here references the canonical name for the FirePHP class
if (!$this->firephp instanceof FirePhp\FirePhpInterface
Expand All @@ -96,8 +103,6 @@ public function getFirePhp()
// FirePHPService is an alias for FirePHP; otherwise the class
// names would clash in this file on this line.
$this->setFirePhp(new FirePhp\FirePhpBridge(new FirePHPService()));
} elseif (!class_exists('FirePHP')) {
throw new RuntimeException('FirePHP Class not found');
}

return $this->firephp;
Expand Down

0 comments on commit 340bd1d

Please sign in to comment.