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.
Completed
Push — devel ( df32c1...525bc2 )
by Alex
04:03 queued 28s
created

OutboxFeature::describe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1.0019

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1.0019
1
<?php
2
namespace PSB\Core\Outbox;
3
4
5
use PSB\Core\Exception\UnexpectedValueException;
6
use PSB\Core\Feature\Feature;
7
use PSB\Core\KnownSettingsEnum;
8
use PSB\Core\ObjectBuilder\BuilderInterface;
9
use PSB\Core\Outbox\Pipeline\OutboxConnector;
10
use PSB\Core\Persistence\StorageType;
11
use PSB\Core\Pipeline\Incoming\IncomingContextFactory;
12
use PSB\Core\Pipeline\Incoming\TransportOperationsConverter;
13
use PSB\Core\Pipeline\Outgoing\OutgoingContextFactory;
14
use PSB\Core\Pipeline\Outgoing\StageContext\DispatchContext;
15
use PSB\Core\Pipeline\PipelineFactory;
16
use PSB\Core\Pipeline\PipelineModifications;
17
use PSB\Core\Util\Settings;
18
19
class OutboxFeature extends Feature
20
{
21
    /**
22
     * Method will always be executed and should be used to determine whether to enable or disable the feature,
23
     * configure default settings, configure dependencies, configure prerequisites and register startup tasks.
24
     */
25 1
    public function describe()
26
    {
27 1
        $this->enableByDefault();
28 1
        $this->registerPrerequisite(
29 1
            function (Settings $settings) {
30
                return !$settings->tryGet(KnownSettingsEnum::SEND_ONLY);
31 1
            },
32 1
            "Endpoint is configured as send only."
33
        );
34 1
    }
35
36
    /**
37
     * Method is called if all defined conditions are met and the feature is marked as enabled.
38
     * Use this method to configure and initialize all required components for the feature like
39
     * the steps in the pipeline or the instances/factories in the container.
40
     *
41
     * @param Settings              $settings
42
     * @param BuilderInterface      $builder
43
     * @param PipelineModifications $pipelineModifications
44
     */
45 2
    public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications)
46
    {
47 2
        $supportedStorageTypes = $settings->get(KnownSettingsEnum::SUPPORTED_STORAGE_TYPE_VALUES);
48 2
        if (!in_array(StorageType::OUTBOX, $supportedStorageTypes)) {
49 1
            throw new UnexpectedValueException(
50
                "Selected persistence doesn't have support for outbox storage. " .
51 1
                "Please select another storage or disable the outbox feature using endpointConfigurator.disableFeature."
52
            );
53
        }
54
55 1
        $pipelineModifications->registerStep(
56 1
            'OutboxConnector',
57 1
            OutboxConnector::class,
58 1
            function () use ($builder) {
59
                /** @var PipelineFactory $pipelineFactory */
60
                $pipelineFactory = $builder->build(PipelineFactory::class);
61
                return new OutboxConnector(
62
                    $pipelineFactory->createStartingWith(
63
                        DispatchContext::class,
64
                        $builder->build(PipelineModifications::class)
65
                    ),
66
                    $builder->build(OutboxStorageInterface::class),
67
                    $builder->build(IncomingContextFactory::class),
68
                    $builder->build(OutgoingContextFactory::class),
69
                    new TransportOperationsConverter(new OutboxTransportOperationFactory())
70
                );
71 1
            }
72
        );
73 1
    }
74
}
75