BuildMessagingPipelines::from()   A
last analyzed

Complexity

Conditions 1
Paths 1

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 1
eloc 2
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Copyright (c) 2017-present Ganbaro Digital Ltd
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 *
13
 *   * Redistributions of source code must retain the above copyright
14
 *     notice, this list of conditions and the following disclaimer.
15
 *
16
 *   * Redistributions in binary form must reproduce the above copyright
17
 *     notice, this list of conditions and the following disclaimer in
18
 *     the documentation and/or other materials provided with the
19
 *     distribution.
20
 *
21
 *   * Neither the names of the copyright holders nor the names of his
22
 *     contributors may be used to endorse or promote products derived
23
 *     from this software without specific prior written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
 * POSSIBILITY OF SUCH DAMAGE.
37
 *
38
 * @category  Libraries
39
 * @package   MessagingPipeline
40
 * @author    Stuart Herbert <[email protected]>
41
 * @copyright 2017-present Ganbaro Digital Ltd www.ganbarodigital.com
42
 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
43
 * @link      http://ganbarodigital.github.io/php-mv-messaging-pipeline
44
 */
45
46
namespace GanbaroDigital\MessagingPipeline\V1;
47
48
use GanbaroDigital\InstructionPipeline\V1\Interfaces\InstructionPipeline;
49
use GanbaroDigital\InstructionPipeline\V1\PipelineBuilders\BuildInstructionPipeline;
50
51
/**
52
 * factory class - assemble a uni-directional or bi-directional messaging
53
 * pipeline from the list of instructions that you supply
54
 */
55
class BuildMessagingPipelines extends BuildInstructionPipeline
56
{
57
    /**
58
     * this is the pipeline that encrypts and signs messages
59
     *
60
     * added for readability
61
     */
62
    const TRANSMIT_PIPELINE = InstructionPipeline::DI_FORWARD;
63
64
    /**
65
     * this is the pipeline that verifies signatures and decrypts messages
66
     *
67
     * added for readability
68
     */
69
    const RECEIVE_PIPELINE = InstructionPipeline::DI_REVERSE;
70
71
    /**
72
     * assemble a pipeline of instructions to execute
73
     *
74
     * @param  array $definition
75
     *         a list of the required instruction builders, and the configs
76
     *         for each builder
77
     * @param  int $directions
78
     *         which pipelines do we want to build? (bitwise mask)
79
     * @return NextInstruction[]
0 ignored issues
show
Documentation introduced by
Should the return type not be InstructionPipeline[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
80
     *         the assembled pipelines
81
     */
82
    public static function from($definition, $directions = InstructionPipeline::DI_FORWARD|InstructionPipeline::DI_REVERSE, $wrapperClass = NextInstruction::class)
83
    {
84
        return parent::from($definition, $directions, $wrapperClass);
0 ignored issues
show
Unused Code introduced by
The call to BuildInstructionPipeline::from() has too many arguments starting with $wrapperClass.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
85
    }
86
}