-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBodyGenerator.php
More file actions
37 lines (29 loc) · 856 Bytes
/
BodyGenerator.php
File metadata and controls
37 lines (29 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* @see https://github.com/open-code-modeling/php-code-ast for the canonical source repository
* @copyright https://github.com/open-code-modeling/php-code-ast/blob/master/COPYRIGHT.md
* @license https://github.com/open-code-modeling/php-code-ast/blob/master/LICENSE.md MIT License
*/
declare(strict_types=1);
namespace OpenCodeModeling\CodeAst\Code;
use PhpParser\Parser;
final class BodyGenerator implements \OpenCodeModeling\CodeAst\StatementGenerator
{
/**
* @var Parser
**/
private $parser;
/**
* @var string
*/
private $code;
public function __construct(Parser $parser, string $code)
{
$this->parser = $parser;
$this->code = $code;
}
public function generate(): ?array
{
return $this->parser->parse('<?php ' . PHP_EOL . $this->code);
}
}