-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIdentifierGenerator.php
More file actions
50 lines (39 loc) · 1.24 KB
/
IdentifierGenerator.php
File metadata and controls
50 lines (39 loc) · 1.24 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
<?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 OpenCodeModeling\CodeAst\IdentifiedStatementGenerator;
use PhpParser\Node\Stmt;
final class IdentifierGenerator implements IdentifiedStatementGenerator
{
/**
* @var \OpenCodeModeling\CodeAst\StatementGenerator
*/
private $statementGenerator;
/**
* @var string
*/
private $identifier;
public function __construct(string $identifier, \OpenCodeModeling\CodeAst\StatementGenerator $statementGenerator)
{
$this->identifier = $identifier;
$this->statementGenerator = $statementGenerator;
}
public function getIdentifier(): string
{
return $this->identifier;
}
public function identifier(): string
{
return $this->identifier;
}
public function generate(): array
{
$stmt = $this->statementGenerator->generate();
return $stmt instanceof Stmt ? [$stmt] : $stmt;
}
}