o2system /
parser
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the O2System Framework package. |
||
| 4 | * |
||
| 5 | * For the full copyright and license information, please view the LICENSE |
||
| 6 | * file that was distributed with this source code. |
||
| 7 | * |
||
| 8 | * @author Steeve Andrian Salim |
||
| 9 | * @copyright Copyright (c) Steeve Andrian Salim |
||
| 10 | */ |
||
| 11 | |||
| 12 | // ------------------------------------------------------------------------ |
||
| 13 | |||
| 14 | namespace O2System\Parser\String\Adapters; |
||
| 15 | |||
| 16 | // ------------------------------------------------------------------------ |
||
| 17 | |||
| 18 | use O2System\Parser\String\Abstracts\AbstractAdapter; |
||
| 19 | use O2System\Spl\Exceptions\RuntimeException; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Class BBCode |
||
| 23 | * |
||
| 24 | * This class driver for Parse BBCode for O2System PHP Framework templating system. |
||
| 25 | * |
||
| 26 | * @package O2System\Parser\Drivers |
||
| 27 | */ |
||
| 28 | class BBCode extends AbstractAdapter |
||
| 29 | {
|
||
| 30 | /** |
||
| 31 | * BBCode::initialize |
||
| 32 | * |
||
| 33 | * @param array $config |
||
| 34 | * |
||
| 35 | * @return static |
||
| 36 | * @throws \O2System\Spl\Exceptions\RuntimeException |
||
| 37 | */ |
||
| 38 | public function initialize(array $config = []) |
||
| 39 | {
|
||
| 40 | if (empty($this->engine)) {
|
||
| 41 | if ($this->isSupported()) {
|
||
| 42 | $this->engine = new \JBBCode\Parser(); |
||
|
0 ignored issues
–
show
|
|||
| 43 | $this->engine->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet()); |
||
|
0 ignored issues
–
show
The type
JBBCode\DefaultCodeDefinitionSet was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 44 | } else {
|
||
| 45 | throw new RuntimeException( |
||
| 46 | 'PARSER_E_THIRD_PARTY', |
||
| 47 | 0, |
||
| 48 | ['BBCode Parser by Jackson Owens', 'https://github.com/jbowens/jBBCode'] |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | return $this; |
||
| 54 | } |
||
| 55 | |||
| 56 | // ------------------------------------------------------------------------ |
||
| 57 | |||
| 58 | /** |
||
| 59 | * BBCode::isSupported |
||
| 60 | * |
||
| 61 | * Checks if this template engine is supported on this system. |
||
| 62 | * |
||
| 63 | * @return bool |
||
| 64 | */ |
||
| 65 | public function isSupported() |
||
| 66 | {
|
||
| 67 | if (class_exists('\JBBCode\Parser')) {
|
||
| 68 | return true; |
||
| 69 | } |
||
| 70 | |||
| 71 | return false; |
||
| 72 | } |
||
| 73 | |||
| 74 | // ------------------------------------------------------------------------ |
||
| 75 | |||
| 76 | /** |
||
| 77 | * BBCode::parse |
||
| 78 | * |
||
| 79 | * @param array $vars Variable to be parsed. |
||
| 80 | * |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | public function parse(array $vars = []) |
||
| 84 | {
|
||
| 85 | $this->engine->parse($this->string); |
||
| 86 | |||
| 87 | return $this->engine->getAsHtml(); |
||
| 88 | } |
||
| 89 | |||
| 90 | // ------------------------------------------------------------------------ |
||
| 91 | |||
| 92 | /** |
||
| 93 | * BBCode::isValidEngine |
||
| 94 | * |
||
| 95 | * Checks if is a valid Object Engine. |
||
| 96 | * |
||
| 97 | * @param object $engine Engine Object Resource. |
||
| 98 | * |
||
| 99 | * @return bool |
||
| 100 | */ |
||
| 101 | protected function isValidEngine($engine) |
||
| 102 | {
|
||
| 103 | if ($engine instanceof \JBBCode\Parser) {
|
||
| 104 | return true; |
||
| 105 | } |
||
| 106 | |||
| 107 | return false; |
||
| 108 | } |
||
| 109 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths