Failed Conditions
Push — master ( 1a5cd4...b0e5e0 )
by Florent
10:14
created

src/Object/RotatableJWKSet.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Object;
13
14
/**
15
 * Class RotatableJWKSet.
16
 */
17
final class RotatableJWKSet extends StorableJWKSet implements RotatableJWKSetInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function rotate()
23
    {
24
        $jwkset = $this->getObject();
25
26
        $keys = $jwkset->getKeys();
27
        unset($keys[count($keys) - 1]);
28
        $jwkset = new JWKSet();
29
        $jwkset->addKey($this->createJWK());
30
        foreach ($keys as $key) {
31
            $jwkset->addKey($key);
32
        }
33
        $this->jwkset = $jwkset;
0 ignored issues
show
The property jwkset does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
        $this->setObject($jwkset);
35
        $this->saveObject($jwkset);
36
    }
37
}
38