GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DynamoDbSessionHandler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 94
ccs 20
cts 20
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A open() 0 4 1
A close() 0 6 1
A destroy() 0 6 1
A gc() 0 6 1
A write() 0 7 1
A read() 0 6 1
1
<?php
2
3
namespace Lightmaker\DynamoSessionHandlerBundle\Session\Storage;
4
5
use Aws\Common\Aws;
6
use Aws\DynamoDb\Session\SessionHandler;
7
8
/**
9
 * DynamoDB session handler
10
 */
11
class DynamoDbSessionHandler implements \SessionHandlerInterface
12
{
13
14
    /**
15
     * @var SessionHandler
16
     */
17
    private $sessionHandler;
18
19
    /**
20
     * Constructor.
21
     *
22
     * See: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/feature-dynamodb-session-handler.html#configuration
23
     *
24
     * List of available options:
25
     *  * table_name: The name of the DynamoDB table in which to store the sessions. This defaults to sessions.
26
     *  * hash_key: The name of the hash key in the DynamoDB sessions table. This defaults to id.
27
     *  * session_lifetime: The lifetime of an inactive session before it should be garbage collected. If it is not provided, then the actual lifetime value that will be used is ini_get('session.gc_maxlifetime').
28
     *  * consistent_read: Whether or not the session handler should use consistent reads for the GetItem operation. This defaults to true.
29
     *  * locking_strategy: The strategy used for doing session locking. By default the handler uses the NullLockingStrategy, which means that session locking is not enabled (see the Session Locking section for more information). Valid values for this option include null, 'null', 'pessemistic', or an instance of NullLockingStrategy or PessimisticLockingStrategy
30
     *  * automatic_gc: Whether or not to use PHP's session auto garbage collection. This defaults to the value of (bool) ini_get('session.gc_probability'), but the recommended value is false. (see the Garbage Collection section for more information).
31
     *  * gc_batch_size: The batch size used for removing expired sessions during garbage collection. This defaults to 25, which is the maximum size of a single BatchWriteItem operation. This value should also take your provisioned throughput into account as well as the timing of your garbage collection.
32
     *  * gc_operation_delay: The delay (in seconds) between service operations performed during garbage collection. This defaults to 0. Increasing this value allows you to throttle your own requests in an attempt to stay within your provisioned throughput capacity during garbage collection.
33
     *  * max_lock_wait_time: Maximum time (in seconds) that the session handler should wait to acquire a lock before giving up. This defaults to 10 and is only used with the PessimisticLockingStrategy.
34
     *  * min_lock_retry_microtime: Minimum time (in microseconds) that the session handler should wait between attempts to acquire a lock. This defaults to 10000 and is only used with the PessimisticLockingStrategy.
35
     *  * max_lock_retry_microtime: Maximum time (in microseconds) that the session handler should wait between attempts to acquire a lock. This defaults to 50000 and is only used with the PessimisticLockingStrategy.
36
     *
37
     * @param Aws   $aws     The AWS SDK for PHP
38
     * @param array $options An associative array of field options (see above)
39
     */
40 6
    public function __construct(Aws $aws, array $options)
41
    {
42 6
        $this->sessionHandler = $aws->get('DynamoDb')->registerSessionHandler($options);
43 6
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    public function open($savePath, $sessionName)
49
    {
50 1
        return $this->sessionHandler->open($savePath, $sessionName);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 1
    public function close()
57
    {
58 1
        $this->sessionHandler->close();
59
60 1
        return true;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 1
    public function destroy($sessionId)
67
    {
68 1
        $this->sessionHandler->destroy($sessionId);
69
70 1
        return true;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 1
    public function gc($maxLifetime)
77
    {
78 1
        $this->sessionHandler->gc($maxLifetime);
79
80 1
        return true;
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86 1
    public function write($sessionId, $data)
87
    {
88
89 1
        $this->sessionHandler->write($sessionId, $data);
90
91 1
        return true;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97 1
    public function read($sessionId)
98
    {
99 1
        $data = $this->sessionHandler->read($sessionId);
100
101 1
        return $data;
102
    }
103
104
}
105