Completed
Pull Request — master (#11)
by
unknown
08:27
created

TokenPersistenceTest::testNullTokenPersistence()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Eljam\GuzzleJwt\Tests\Persistence;
4
5
use Eljam\GuzzleJwt\JwtToken;
6
use Eljam\GuzzleJwt\Persistence\NullTokenPersistence;
7
8
/**
9
 * @author Nicolas Reynis (nreynis)
10
 */
11
class TokenPersistenceTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * testNullTokenPersistence.
15
     */
16
    public function testNullTokenPersistence()
17
    {
18
        $tokenPersistence = new NullTokenPersistence();
19
        $token = new JwtToken('foo', new \DateTime('now'));
20
21
        $tokenPersistence->saveToken($token);
0 ignored issues
show
Unused Code introduced by
The call to the method Eljam\GuzzleJwt\Persiste...ersistence::saveToken() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
22
23
        $this->assertFalse($tokenPersistence->hasToken());
24
        $this->assertNull($tokenPersistence->restoreToken());
25
    }
26
}
27