MBHFramework/structures

View on GitHub
Mbh/Traits/EmptyGuard.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php namespace Mbh\Traits;

/**
 * MBHFramework
 *
 * @link      https://github.com/MBHFramework/mbh-framework
 * @copyright Copyright (c) 2017 Ulises Jeremias Cornejo Fandos
 * @license   https://github.com/MBHFramework/mbh-framework/blob/master/LICENSE (MIT License)
 */

use Mbh\Exceptions\EmptyException;

/**
 * Common to structures that require an empty guard.
 */
trait EmptyGuard
{
    protected function emptyGuard($method)
    {
        if ($this->isEmpty()) {
            throw EmptyException::cannotAccessWhenEmpty(__CLASS__, $method);
        }
    }

    abstract public function isEmpty(): bool;
}