| 1 | <?php |
||
| 18 | class Esprima implements EngineInterface |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * File locator |
||
| 22 | * |
||
| 23 | * @var \Symfony\Component\Config\FileLocatorInterface |
||
| 24 | * @access protected |
||
| 25 | */ |
||
| 26 | protected $locator; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Esprima file. |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | * @access protected |
||
| 33 | */ |
||
| 34 | protected $file; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Esprima script. |
||
| 38 | * |
||
| 39 | * @var string |
||
| 40 | * @access protected |
||
| 41 | */ |
||
| 42 | protected $esprima; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Internal constructor. |
||
| 46 | * |
||
| 47 | * @access public |
||
| 48 | * @param \Symfony\Component\Config\FileLocatorInterface $locator |
||
| 49 | * @param string $file |
||
| 50 | * @return void |
||
|
|
|||
| 51 | */ |
||
| 52 | 6 | public function __construct($locator, $file) |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Returns engine as string. |
||
| 60 | * |
||
| 61 | * @access public |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | 17 | public function toString() |
|
| 70 | |||
| 71 | /** |
||
| 72 | * To string magic method. |
||
| 73 | * |
||
| 74 | * @access public |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | public function __toString() |
||
| 78 | { |
||
| 79 | return $this->toString(); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Load esprima script. |
||
| 84 | * |
||
| 85 | * @access public |
||
| 86 | * @return string |
||
| 87 | */ |
||
| 88 | 17 | public function load() |
|
| 89 | { |
||
| 90 | 17 | if (!$this->esprima) { |
|
| 91 | |||
| 92 | 6 | $this->esprima = $this->loadFile( |
|
| 93 | 6 | $this->locator->locate($this->file) |
|
| 94 | ); |
||
| 95 | } |
||
| 96 | |||
| 97 | 17 | return $this->esprima; |
|
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Load procedure file content. |
||
| 102 | * |
||
| 103 | * @access protected |
||
| 104 | * @param string $file |
||
| 105 | * @return string |
||
| 106 | */ |
||
| 107 | 6 | protected function loadFile($file) |
|
| 111 | } |
||
| 112 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.