StateStorage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 3 1
A __construct() 0 3 1
A has() 0 3 2
A clear() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\OAuth2\Client\Example;
5
6
/**
7
 * Classe auxiliar para armazenar o "state" na sessão
8
 */
9
class StateStorage
10
{
11
    public function __construct()
12
    {
13
        @session_start();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for session_start(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

13
        /** @scrutinizer ignore-unhandled */ @session_start();

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
14
    }
15
16
    public function store($v): void
17
    {
18
        $_SESSION['oauth'] = $v;
19
    }
20
21
    public function has($v): bool
22
    {
23
        return isset($_SESSION['oauth']) && $_SESSION['oauth'] === $v;
24
    }
25
26
    public function clear(): void
27
    {
28
        unset($_SESSION['oauth']);
29
    }
30
}
31