GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SimpleMessageBusBuilder::defaultName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 34 and the first side effect is on line 196.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 * Copyright (c) 2014 Janos Szurovecz
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6
 * this software and associated documentation files (the "Software"), to deal in
7
 * the Software without restriction, including without limitation the rights to
8
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
 * of the Software, and to permit persons to whom the Software is furnished to do
10
 * so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in all
13
 * copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
24
namespace predaddy\messagehandling;
25
26
use predaddy\messagehandling\annotation\AnnotatedMessageHandlerDescriptorFactory;
27
28
/**
29
 * Builder for {@link SimpleMessageBus}.
30
 *
31
 * @package predaddy\messagehandling
32
 * @author Janos Szurovecz <[email protected]>
33
 */
34
class SimpleMessageBusBuilder
35
{
36
    const DEFAULT_NAME = 'message-bus';
37
38
    /**
39
     * @var AnnotatedMessageHandlerDescriptorFactory
40
     */
41
    private static $defaultHandlerDescFactory;
42
43
    /**
44
     * @var NullSubscriberExceptionHandler
45
     */
46
    private static $defaultExceptionHandler;
47
48
    /**
49
     * @var string
50
     */
51
    private $identifier;
52
53
    /**
54
     * @var DispatchInterceptor[]
55
     */
56
    private $interceptors = [];
57
58
    /**
59
     * @var SubscriberExceptionHandler
60
     */
61
    private $exceptionHandler;
62
63
    /**
64
     * @var MessageHandlerDescriptorFactory
65
     */
66
    private $handlerDescriptorFactory;
67
68
    public function __construct()
69
    {
70
        $this->exceptionHandler = static::defaultExceptionHandler();
71
        $this->handlerDescriptorFactory = static::defaultHandlerDescFactory();
72
        $this->identifier = static::defaultName();
73
    }
74
75
    /**
76
     * Should not be called!
77
     */
78
    public static function init()
79
    {
80
        self::$defaultHandlerDescFactory = new AnnotatedMessageHandlerDescriptorFactory(
81
            new DefaultFunctionDescriptorFactory()
82
        );
83
        self::$defaultExceptionHandler = new NullSubscriberExceptionHandler();
84
    }
85
86
    /**
87
     * Override if the default name should be modified.
88
     *
89
     * @return string
90
     */
91
    protected static function defaultName()
92
    {
93
        return self::DEFAULT_NAME;
94
    }
95
96
    /**
97
     * Override if the default factory should be modified.
98
     *
99
     * @return AnnotatedMessageHandlerDescriptorFactory
100
     */
101
    protected static function defaultHandlerDescFactory()
102
    {
103
        return self::$defaultHandlerDescFactory;
104
    }
105
106
    /**
107
     * Override if the default exception handler should be modified.
108
     *
109
     * @return NullSubscriberExceptionHandler
110
     */
111
    protected static function defaultExceptionHandler()
112
    {
113
        return self::$defaultExceptionHandler;
114
    }
115
116
    /**
117
     * @return SimpleMessageBus
118
     */
119
    public function build()
120
    {
121
        return new SimpleMessageBus($this);
122
    }
123
124
    /**
125
     * @param $identifier
126
     * @return $this
127
     */
128
    public function withIdentifier($identifier)
129
    {
130
        $this->identifier = (string) $identifier;
131
        return $this;
132
    }
133
134
    /**
135
     * @param DispatchInterceptor[] $interceptors
136
     * @return $this
137
     */
138
    public function withInterceptors(array $interceptors)
139
    {
140
        $this->interceptors = $interceptors;
141
        return $this;
142
    }
143
144
    /**
145
     * @param SubscriberExceptionHandler $exceptionHandler
146
     * @return $this
147
     */
148
    public function withExceptionHandler(SubscriberExceptionHandler $exceptionHandler)
149
    {
150
        $this->exceptionHandler = $exceptionHandler;
151
        return $this;
152
    }
153
154
    /**
155
     * @param MessageHandlerDescriptorFactory $descriptorFactory
156
     * @return $this
157
     */
158
    public function withHandlerDescriptorFactory(MessageHandlerDescriptorFactory $descriptorFactory)
159
    {
160
        $this->handlerDescriptorFactory = $descriptorFactory;
161
        return $this;
162
    }
163
164
    /**
165
     * @return SubscriberExceptionHandler
166
     */
167
    public function getExceptionHandler()
168
    {
169
        return $this->exceptionHandler;
170
    }
171
172
    /**
173
     * @return MessageHandlerDescriptorFactory
174
     */
175
    public function getHandlerDescriptorFactory()
176
    {
177
        return $this->handlerDescriptorFactory;
178
    }
179
180
    /**
181
     * @return string
182
     */
183
    public function getIdentifier()
184
    {
185
        return $this->identifier;
186
    }
187
188
    /**
189
     * @return DispatchInterceptor[]
190
     */
191
    public function getInterceptors()
192
    {
193
        return $this->interceptors;
194
    }
195
}
196
SimpleMessageBusBuilder::init();
197