1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Oryzone PHPoAuthUserData package <https://github.com/Oryzone/PHPoAuthUserData>. |
5
|
|
|
* |
6
|
|
|
* (c) Oryzone, developed by Luciano Mammino <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace OAuth\UserData\Exception; |
13
|
|
|
|
14
|
|
|
use OAuth\Common\Service\ServiceInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class UnmatchedExtractorException |
18
|
|
|
* @package OAuth\UserData\Exception |
19
|
|
|
*/ |
20
|
|
|
class UndefinedExtractorException extends \Exception implements Exception |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \OAuth\Common\Service\ServiceInterface $service |
24
|
|
|
*/ |
25
|
|
|
protected $service; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var array $registeredExtractors |
29
|
|
|
*/ |
30
|
|
|
protected $registeredExtractors; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructor |
34
|
|
|
* |
35
|
|
|
* @param \OAuth\Common\Service\ServiceInterface $service |
36
|
|
|
* @param array $registeredExtractors |
37
|
|
|
* @param string|null $message |
38
|
|
|
*/ |
39
|
|
|
public function __construct(ServiceInterface $service, $registeredExtractors = array(), $message = null) |
40
|
|
|
{ |
41
|
|
|
$this->service = $service; |
42
|
|
|
$this->registeredExtractors = $registeredExtractors; |
43
|
|
|
if (null === $message) { |
44
|
|
|
$message = sprintf( |
45
|
|
|
'Cannot find an extractor for the service "%s". Registered extractors: %s', |
46
|
|
|
get_class($service), |
47
|
|
|
json_encode($registeredExtractors) |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
parent::__construct($message); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get the service |
55
|
|
|
* |
56
|
|
|
* @return ServiceInterface |
57
|
|
|
*/ |
58
|
|
|
public function getService() |
59
|
|
|
{ |
60
|
|
|
return $this->service; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get registered extractors |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
public function getRegisteredExtractors() |
69
|
|
|
{ |
70
|
|
|
return $this->registeredExtractors; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|