-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathPackageReader.php
More file actions
45 lines (37 loc) · 1.05 KB
/
PackageReader.php
File metadata and controls
45 lines (37 loc) · 1.05 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
<?php
declare(strict_types=1);
namespace PHPJava\Core\Stream\Reader;
use PHPJava\Core\JVM\Stream\ReflectionClassReader;
use PHPJava\Core\JVM\Stream\StreamReaderInterface;
use PHPJava\Utilities\Formatter;
class PackageReader implements ReaderInterface
{
private $classPath;
/**
* @var ReflectionClassReader
*/
private $reflectionClassReader;
public function __construct(string $classPath)
{
[, $this->classPath] = Formatter::convertJavaNamespaceToPHP($classPath);
$this->reflectionClassReader = new ReflectionClassReader(
new \ReflectionClass($this->classPath)
);
}
public function getReader(): StreamReaderInterface
{
return $this->reflectionClassReader;
}
public function getJavaPathName(): string
{
return Formatter::convertJavaNamespaceToPHP($this->classPath)[1];
}
public function getFileName(): string
{
return basename($this->classPath);
}
public function __toString(): string
{
return $this->getFileName();
}
}