Skip to content

Commit

Permalink
static exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
devosc committed Nov 20, 2016
1 parent d0105a4 commit f15ff96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/Template/Section/Push.php
Expand Up @@ -6,6 +6,8 @@

namespace View5\Template\Section;

use Mvc5\Exception;

trait Push
{
/**
Expand Down Expand Up @@ -54,9 +56,8 @@ function startPush($section, $content = '')
*/
function stopPush()
{
if (!$this->pushStack) {
throw new \InvalidArgumentException('Cannot end a section without first starting one.');
}
!$this->pushStack &&
Exception::invalidArgument('Cannot end a section without first starting one.');

$last = array_pop($this->pushStack);

Expand Down
12 changes: 6 additions & 6 deletions src/Template/Section/Stack.php
Expand Up @@ -6,6 +6,8 @@

namespace View5\Template\Section;

use Mvc5\Exception;

trait Stack
{
/**
Expand All @@ -24,9 +26,8 @@ trait Stack
*/
function appendSection()
{
if (!$this->sectionStack) {
throw new \InvalidArgumentException('Cannot end a section without first starting one.');
}
!$this->sectionStack &&
Exception::invalidArgument('Cannot end a section without first starting one.');

$last = array_pop($this->sectionStack);

Expand Down Expand Up @@ -103,9 +104,8 @@ function startSection($section, $content = '')
*/
function stopSection($overwrite = false)
{
if (!$this->sectionStack) {
throw new \InvalidArgumentException('Cannot end a section without first starting one.');
}
!$this->sectionStack &&
Exception::invalidArgument('Cannot end a section without first starting one.');

$last = array_pop($this->sectionStack);

Expand Down

0 comments on commit f15ff96

Please sign in to comment.