Passed
Push — master ( a5e8db...945884 )
by Danny
02:33
created

Rewrite   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rewriteFlush() 0 4 1
A rewriteSetStructure() 0 9 3
1
<?php
2
namespace PressCLI\WPCLI;
3
4
use PressCLI\WPCLI\CLI;
5
use PressCLI\Option\Configuration;
6
7
trait Rewrite
8
{
9
    /**
10
     * Flushes the rewrite rules.
11
     */
12
    public static function rewriteFlush()
13
    {
14
        CLI::execCommand('rewrite', ['flush']);
15
    }
16
17
    /**
18
     * Sets the default permalink rewrite structure.
19
     */
20
    public static function rewriteSetStructure()
21
    {
22
        $config = Configuration::get();
23
        $rewrite = isset($config['rewrite']) ? $config['rewrite'] : [];
24
        $rewrite = isset($rewrite['structure']) ? $rewrite['structure'] : '/%postname%/';
25
26
        CLI::execCommand('rewrite', ['structure', "'{$rewrite}'"], ['hard' => '']);
27
        CLI::execCommand('rewrite', ['flush'], ['hard' => '']);
28
    }
29
}
30