1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace UCD\Infrastructure\Repository\CharacterRepository; |
4
|
|
|
|
5
|
|
|
use Psr\Log\LoggerInterface; |
6
|
|
|
|
7
|
|
|
use UCD\Unicode\Character\Properties\General\Block; |
8
|
|
|
use UCD\Unicode\Codepoint; |
9
|
|
|
use UCD\Unicode\Character\Repository; |
10
|
|
|
use UCD\Unicode\CodepointAssigned; |
11
|
|
|
|
12
|
|
|
class DebugRepository implements Repository |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var Repository |
16
|
|
|
*/ |
17
|
|
|
protected $delegate; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var LoggerInterface |
21
|
|
|
*/ |
22
|
|
|
private $logger; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param Repository $delegate |
26
|
|
|
* @param LoggerInterface $logger |
27
|
|
|
*/ |
28
|
|
|
public function __construct(Repository $delegate, LoggerInterface $logger) |
29
|
|
|
{ |
30
|
|
|
$this->delegate = $delegate; |
31
|
|
|
$this->logger = $logger; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritDoc} |
36
|
|
|
*/ |
37
|
|
|
public function getByCodepoint(Codepoint $codepoint) |
38
|
|
|
{ |
39
|
|
|
$message = $this->composeMessage(__FUNCTION__, [$codepoint]); |
40
|
|
|
$this->log($message); |
41
|
|
|
|
42
|
|
|
return $this->delegate->getByCodepoint($codepoint); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritDoc} |
47
|
|
|
*/ |
48
|
|
|
public function getByCodepoints(Codepoint\Collection $codepoints) |
49
|
|
|
{ |
50
|
|
|
$message = $this->composeMessage(__FUNCTION__, [$codepoints]); |
51
|
|
|
$this->log($message); |
52
|
|
|
|
53
|
|
|
return $this->delegate->getByCodepoints($codepoints); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritDoc} |
58
|
|
|
*/ |
59
|
|
|
public function getAll() |
60
|
|
|
{ |
61
|
|
|
$message = $this->composeMessage(__FUNCTION__); |
62
|
|
|
$this->log($message); |
63
|
|
|
|
64
|
|
|
return $this->delegate->getAll(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritDoc} |
69
|
|
|
*/ |
70
|
|
|
public function getCodepointsByBlock(Block $block) |
71
|
|
|
{ |
72
|
|
|
$message = $this->composeMessage(__FUNCTION__); |
73
|
|
|
$this->log($message); |
74
|
|
|
|
75
|
|
|
return $this->delegate->getCodepointsByBlock($block); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritDoc} |
80
|
|
|
*/ |
81
|
|
|
public function count() |
82
|
|
|
{ |
83
|
|
|
$message = $this->composeMessage(__FUNCTION__); |
84
|
|
|
$this->log($message); |
85
|
|
|
|
86
|
|
|
return $this->delegate->count(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $method |
91
|
|
|
* @param array $details |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
protected function composeMessage($method, array $details = []) |
95
|
|
|
{ |
96
|
|
|
return sprintf('Repository::%s/%s', $method, json_encode($details)); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $message |
101
|
|
|
*/ |
102
|
|
|
protected function log($message) |
103
|
|
|
{ |
104
|
|
|
$this->logger->info($message); |
105
|
|
|
} |
106
|
|
|
} |