Passed
Push — master ( 138b71...c5c69e )
by Sebastian
04:58
created

Mailcode_Factory_CommandSets_Set::end()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 17
rs 9.9666
1
<?php
2
/**
3
 * File containing the {@see Mailcode_Factory} class.
4
 *
5
 * @package Mailcode
6
 * @subpackage Utilities
7
 * @see Mailcode_Factory
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
/**
15
 * Factory utility used to create commands.
16
 *
17
 * @package Mailcode
18
 * @subpackage Utilities
19
 * @author Sebastian Mordziol <[email protected]>
20
 */
21
abstract class Mailcode_Factory_CommandSets_Set
22
{
23
   /**
24
    * @var Mailcode_Factory_Instantiator
25
    */
26
    protected $instantiator;
27
    
28
    public function __construct()
29
    {
30
        $this->instantiator = new Mailcode_Factory_Instantiator();
31
    }
32
    
33
    public function end() : Mailcode_Commands_Command_End
34
    {
35
        $cmd = Mailcode::create()->getCommands()->createCommand(
36
            'End',
37
            '',
38
            '',
39
            '{end}'
40
        );
41
        
42
        $this->instantiator->checkCommand($cmd);
43
        
44
        if($cmd instanceof Mailcode_Commands_Command_End)
45
        {
46
            return $cmd;
47
        }
48
        
49
        throw $this->instantiator->exceptionUnexpectedType('End', $cmd);
50
    }
51
}
52