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

ThemePublisher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A publish() 0 8 2
A setTheme() 0 4 1
A theme() 0 3 1
A __construct() 0 3 1
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
}