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

CompileObjectGraph   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 7 1
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