| 1 | <?php |
||
| 8 | final class RegexpObscuredStrategy implements StrategyInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | private $pattern; |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $replacement; |
||
| 18 | |||
| 19 | 30 | public function __construct(string $pattern, string $replacement = '') |
|
| 24 | |||
| 25 | /** |
||
| 26 | * @inheritdoc |
||
| 27 | */ |
||
| 28 | 20 | public function extract($value) |
|
| 29 | { |
||
| 30 | 20 | if (!empty($value) && preg_match($this->pattern, $value)) { |
|
| 31 | 2 | return preg_replace($this->pattern, $this->replacement, $value); |
|
| 32 | } |
||
| 33 | |||
| 34 | 18 | return $value; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @inheritdoc |
||
| 39 | */ |
||
| 40 | 6 | public function hydrate($value) |
|
| 44 | } |
||
| 45 |