MemoryRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 14
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A save() 0 3 1
A find() 0 3 1
1
<?php
2
3
/**
4
 * Liaison de compte utilisateur par redirection.
5
 *
6
 * @see https://github.com/NextINpact/LaPresseLibreSDK/wiki/Liaison-de-compte-utilisateur-par-redirection
7
 */
8
9
require 'bootstrap.php';
10
11
use Mediapart\LaPresseLibre\Account\Liaison;
0 ignored issues
show
Bug introduced by
The type Mediapart\LaPresseLibre\Account\Liaison was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Mediapart\LaPresseLibre\Account\Account;
13
use Mediapart\LaPresseLibre\Account\Repository;
14
15
class MemoryRepository implements Repository
16
{
17
	private $accounts = [];
18
	public function __construct($accounts)
19
	{
20
		array_map([$this, 'save'], $accounts);
21
	}
22
	public function find($code)
23
	{
24
		return $this->accounts[$code];
25
	}
26
	public function save(Account $account)
27
	{
28
		$this->accounts[$account->getCode()] = $account;
29
	}
30
}
31
32
$repository = new MemoryRepository([
33
	new Account('[email protected]', '99f104e8-2fa3-4a77-1664-5bac75fb668d'),
34
	new Account('[email protected]', '68b3c837-c7f4-1b54-2efa-1c5cc2945c3f'),
35
]);
36
$logguedAccount = new Account('[email protected]', '7f75e972-d5c7-b0c5-1a1b-9d5a582cbd27');
37
38
$liaison = new Liaison($encryption, $repository, $public_key);
39
$redirection = $liaison->generateUrl($_GET['lpluser'], $logguedAccount);
40
41
header('Location: '.$redirection);
42