MessageIssueInstantAction::doExecute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Action\Profile\Outbound\Message;
13
14
use LightSaml\Action\Profile\AbstractProfileAction;
15
use LightSaml\Context\Profile\Helper\LogHelper;
16
use LightSaml\Context\Profile\Helper\MessageContextHelper;
17
use LightSaml\Context\Profile\ProfileContext;
18
use LightSaml\Provider\TimeProvider\TimeProviderInterface;
19
use Psr\Log\LoggerInterface;
20
21
/**
22
 * Sets outbound message IssueInstant to the value provided by given time provider.
23
 */
24
class MessageIssueInstantAction extends AbstractProfileAction
25
{
26
    /** @var TimeProviderInterface */
27
    protected $timeProvider;
28
29
    public function __construct(LoggerInterface $logger, TimeProviderInterface $timeProvider)
30
    {
31
        parent::__construct($logger);
32
33
        $this->timeProvider = $timeProvider;
34
    }
35
36
    /**
37
     * @return void
38
     */
39
    protected function doExecute(ProfileContext $context)
40
    {
41
        MessageContextHelper::asSamlMessage($context->getOutboundContext())
42
            ->setIssueInstant($this->timeProvider->getTimestamp());
43
44
        $this->logger->info(
45
            sprintf('Message IssueInstant set to "%s"', MessageContextHelper::asSamlMessage($context->getOutboundContext())->getIssueInstantString()),
46
            LogHelper::getActionContext($context, $this)
47
        );
48
    }
49
}
50