nexuslinkservices /
email-link-highlighter
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the Link Highlighter Package |
||
| 5 | * |
||
| 6 | * (c) Nexuslink Services |
||
| 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 Highlighter; |
||
| 13 | |||
| 14 | use Symfony\Component\Yaml\Yaml; |
||
| 15 | use Highlighter\src\Services\LinkHighlighter; |
||
| 16 | use Highlighter\src\Services\MailToHighlighter; |
||
| 17 | |||
| 18 | class Highlighter { |
||
| 19 | |||
| 20 | private $pathToYml; |
||
| 21 | |||
| 22 | public function __construct($pathToYml = '') { |
||
| 23 | |||
| 24 | if (!empty($pathToYml)) { |
||
| 25 | $this->pathToYml = $pathToYml; |
||
| 26 | } else { |
||
| 27 | $this->pathToYml = __DIR__ . "\Resources\config\config.yml"; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * |
||
| 33 | * @param string $content |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | public function HighLight($content) { |
||
| 37 | |||
| 38 | $configArray = Yaml::parse(file_get_contents($this->pathToYml)); |
||
| 39 | |||
| 40 | if ($configArray['high_lighter']['link']) { |
||
| 41 | $content = LinkHighlighter::replaceWebLinks($content); |
||
| 42 | } |
||
| 43 | if ($configArray['high_lighter']['mail']) { |
||
| 44 | $content = MailToHighlighter::replaceMailTo($content); |
||
| 45 | } |
||
| 46 | return $content; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | private function getPathToYml() { |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 54 | |||
| 55 | return $this->pathToYml; |
||
| 56 | } |
||
| 57 | |||
| 58 | } |
||
| 59 |