Passed
Push — master ( df324d...7773d7 )
by Caen
03:06 queued 14s
created

ResetsApplication::restoreDefaultPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Hyde\Testing;
4
5
use Hyde\Framework\Hyde;
6
7
/**
8
 * @internal
9
 */
10
trait ResetsApplication
11
{
12
    public function resetApplication(): void
13
    {
14
        $this->resetMedia();
15
        $this->resetPages();
16
        $this->resetPosts();
17
        $this->resetDocs();
18
        $this->resetSite();
19
    }
20
21
    public function resetMedia(): void
22
    {
23
        //
24
    }
25
26
    public function resetPages(): void
27
    {
28
        array_map('unlinkUnlessDefault', glob(Hyde::path('_pages/*.md')));
29
        array_map('unlinkUnlessDefault', glob(Hyde::path('_pages/*.blade.php')));
30
    }
31
32
    public function resetPosts(): void
33
    {
34
        array_map('unlinkUnlessDefault', glob(Hyde::path('_posts/*.md')));
35
    }
36
37
    public function resetDocs(): void
38
    {
39
        array_map('unlinkUnlessDefault', glob(Hyde::path('_docs/*.md')));
40
    }
41
42
    public function resetSite(): void
43
    {
44
        array_map('unlinkUnlessDefault', glob(Hyde::path('_site/**/*.html')));
45
        array_map('unlinkUnlessDefault', glob(Hyde::path('_site/**/*.json')));
46
        array_map('unlinkUnlessDefault', glob(Hyde::path('_site/*.xml')));
47
    }
48
49
    public function restoreDefaultPages(): void
50
    {
51
        copy(Hyde::vendorPath('resources/views/homepages/welcome.blade.php'), Hyde::path('_pages/index.blade.php'));
52
        copy(Hyde::vendorPath('resources/views/pages/404.blade.php'), Hyde::path('_pages/404.blade.php'));
53
    }
54
}
55