forked from italia/spid-php-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sp.php
38 lines (33 loc) · 1.16 KB
/
Sp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Italia\Spid;
class Sp
{
/*
* Strategy pattern: initialize the requested protocol based on name provided.
* Currently only SAML solution is implemented
* Method calls on Sp call the equivalent method in the chosen strategy implementation
* Please check SAMLInterface for available methods for SAML Strategy
*/
private $protocol;
public function __construct(array $settings, String $protocol = null, $autoconfigure = true)
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
switch ($protocol) {
case 'saml':
$this->protocol = new Spid\Saml($settings, $autoconfigure);
break;
default:
$this->protocol = new Spid\Saml($settings, $autoconfigure);
}
}
public function __call($method, $arguments)
{
$methods_implemented = get_class_methods($this->protocol);
if (!in_array($method, $methods_implemented)) {
throw new \Exception("Invalid method [$method] requested", 1);
}
return call_user_func_array(array($this->protocol, $method), $arguments);
}
}