Passed
Branch feature/refactoring-samurai (b4e88e)
by Giuliano
03:41
created

ThemePublisher::publish()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Maestriam\Samurai\Foundation;
4
5
use Illuminate\Support\Facades\File;
6
use Maestriam\Samurai\Entities\Theme;
7
8
class ThemePublisher
9
{
10
    private Theme $themeInstance;
11
12
    public function __construct(Theme $theme)
13
    {
14
        $this->setTheme($theme);
15
    }    
16
17
    public function publish()
18
    {
19
        $from = $this->theme()->paths()->assets();
20
        $to   = $this->theme()->paths()->public();
21
22
        File::copyDirectory($from, $to);
23
24
        return (is_dir($to)) ? true : false;
25
    }
26
27
    private function theme() : Theme 
28
    {
29
        return $this->themeInstance;
30
    }
31
32
    private function setTheme(Theme $theme) : ThemePublisher
33
    {
34
        $this->themeInstance = $theme;
35
        return $this;        
36
    }
37
}