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

Expiration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 5 1
A invokeTest() 0 16 3
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