Completed
Push — master ( 899d3f...372717 )
by Tim
08:54 queued 02:29
created

Expiration::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor\TestCase\Metadata;
4
5
use \SimpleSAML\Module\monitor\State as State;
6
7
final class Expiration extends \SimpleSAML\Module\monitor\TestCase
0 ignored issues
show
Coding Style introduced by
Expiration does not seem to conform to the naming convention (^sspmod_monitor_([A-Z][a-zA-Z0-9_]+)+$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
8
{
9
    private $entityId = null;
10
    private $metadata = null;
11
12
    /*
13
     * @return void
14
     */
15
    protected function initialize()
16
    {
17
        $this->entityId = $this->getInput('entityId');
18
        $this->metadata = $this->getInput('metadata');
19
    }
20
21
    /*
22
     * @return void
23
     */
24
    protected function invokeTest()
25
    {
26
        if (array_key_exists('expire', $this->metadata)) {
27
            $expiration = $this->metadata['expire'];
28
            if ($expiration <= time()) {
29
                $this->setState(State::ERROR);
30
                $this->addMessage(State::ERROR, 'Metadata expiration', $this->entityId, 'Metadata has expired');
31
            } else {
32
                $this->setState(State::OK);
33
                $this->addMessage(State::OK, 'Metadata expiration', $this->entityId, 'Metadata will expire on ' . strftime('%c', $expiration));
34
            }
35
        } else {
36
            $this->setState(State::OK);
37
            $this->addMessage(State::OK, 'Metadata expiration', $this->entityId, 'Metadata never expires');
38
        }
39
    }
40
}
41
42