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

ResetsApplication   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 43
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A resetPosts() 0 3 1
A resetMedia() 0 2 1
A resetPages() 0 4 1
A resetApplication() 0 7 1
A resetSite() 0 5 1
A resetDocs() 0 3 1
A restoreDefaultPages() 0 4 1
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