Skip to content

Commit

Permalink
Resolve PHPMD warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t authored and retlehs committed Mar 11, 2016
1 parent 6a4d3bd commit c5f3724
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@
use Roots\Sage\Template\WrapperCollection;
use Roots\Sage\Template\WrapperInterface;

/**
* @param WrapperInterface $wrapper
* @param string $slug
* @return string
* @throws \Exception
* @SuppressWarnings(PHPMD.StaticAccess) This is a helper function, so we can suppress this warning
*/
function template_wrap(WrapperInterface $wrapper, $slug = 'base') {
WrapperCollection::add($wrapper, $slug);
return $wrapper->getWrapper();
}

/**
* @param string $slug
* @return string
*/
function template_unwrap($slug = 'base') {
return WrapperCollection::get($slug)->getTemplate();
}
Expand Down
5 changes: 2 additions & 3 deletions src/lib/Sage/Template/WrapperCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ public static function instance()
/**
* @param WrapperInterface $wrapper
* @param string $slug
* @param bool $overwriteIfExists
* @return $this
* @throws \Exception
*/
public static function add(WrapperInterface $wrapper, $slug = '', $overwriteIfExists = false)
public static function add(WrapperInterface $wrapper, $slug = '')
{
$slug = $slug ?: $wrapper->getSlug();
if (self::instance()->exists($slug) && !$overwriteIfExists) {
if (self::instance()->exists($slug)) {
throw new \Exception("Wrapper $slug already exists.");
}
self::instance()->wrappers[$slug] = $wrapper;
Expand Down

0 comments on commit c5f3724

Please sign in to comment.