EmptyGuard::emptyGuard()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php namespace Mbh\Traits;
2
3
/**
4
 * MBHFramework
5
 *
6
 * @link      https://github.com/MBHFramework/mbh-framework
7
 * @copyright Copyright (c) 2017 Ulises Jeremias Cornejo Fandos
8
 * @license   https://github.com/MBHFramework/mbh-framework/blob/master/LICENSE (MIT License)
9
 */
10
11
use Mbh\Exceptions\EmptyException;
12
13
/**
14
 * Common to structures that require an empty guard.
15
 */
16
trait EmptyGuard
17
{
18
    protected function emptyGuard($method)
19
    {
20
        if ($this->isEmpty()) {
21
            throw EmptyException::cannotAccessWhenEmpty(__CLASS__, $method);
22
        }
23
    }
24
25
    abstract public function isEmpty(): bool;
26
}
27