Completed
Push — 1.x ( fd0c91...cdd807 )
by Akihito
03:35
created

CompileObjectGraph::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Compiler;
6
7
use Ray\Di\AbstractModule;
8
use Ray\ObjectGrapher\ObjectGrapher;
9
10
use function sprintf;
11
12
final class CompileObjectGraph
13
{
14
    /** @var FilePutContents */
15
    private $filePutContents;
16
17
    /** @var string */
18
    private $appDir;
19
20
    public function __construct(FilePutContents $filePutContents, string $appDir)
21
    {
22
        $this->filePutContents = $filePutContents;
23
        $this->appDir = $appDir;
24
    }
25
26
    public function __invoke(AbstractModule $module): string
27
    {
28
        $dotFile = sprintf('%s/module.dot', $this->appDir);
29
        ($this->filePutContents)($dotFile, (new ObjectGrapher())($module));
30
31
        return $dotFile;
32
    }
33
}
34