MissingBlockException::missingBlock()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace TheCodingMachine\Mail\Template;
4
5
class MissingBlockException extends \RuntimeException implements MailTemplateException
6
{
7
    /**
8
     * @param array $blockNames
9
     *
10
     * @return MissingBlockException
11
     */
12 1
    public static function missingBlock(array $blockNames):MissingBlockException
13
    {
14 1
        $blocksName = implode(',', $blockNames);
15 1
        $errorMsg = ($blocksName === '') ? 'No blocks found.' : 'Blocks found '.$blocksName.'.';
16
17 1
        return new self('Your template needs a subject block and a body_html or a body_text block.'.$errorMsg);
18
    }
19
}
20