Separate text filter decorators.
This commit is contained in:
27
app/Decorators/TraficarDecorator.php
Normal file
27
app/Decorators/TraficarDecorator.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: k
|
||||
* Date: 28.02.2019
|
||||
* Time: 22:20
|
||||
*/
|
||||
|
||||
namespace App\Decorators;
|
||||
|
||||
|
||||
use App\Paper\Traficar;
|
||||
|
||||
class TraficarDecorator extends TextConverterDecorator
|
||||
{
|
||||
|
||||
public function getText(): string
|
||||
{
|
||||
$text = $this->text->getText();
|
||||
if (strstr($text, '[traficar]')) {
|
||||
$traficar = new Traficar();
|
||||
$nearest = $traficar->nearestCarText();
|
||||
$text = str_replace('[traficar]', $nearest, $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user