Completed
Push — master ( ce9eda...f41b2c )
by Mahmoud
03:36
created

ProcessMarkdownTemplatesTask   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 1
1
<?php
2
3
namespace App\Containers\Documentation\Tasks;
4
5
use App\Containers\Documentation\Traits\DocsGeneratorTrait;
6
use App\Ship\Parents\Tasks\Task;
7
use Illuminate\Support\Facades\Config;
8
9
/**
10
 * Class ProcessMarkdownTemplatesTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class ProcessMarkdownTemplatesTask extends Task
15
{
16
    use DocsGeneratorTrait;
17
18
    protected $headerMarkdownContent;
19
20
    const TEMPLATE_PATH = 'Containers/Documentation/ApiDocJs/shared/';
21
    const OUTPUT_PATH = 'api-markdowns/';
22
23
    /**
24
     * Read the markdown header template and fill it with some real data from the .env file.
25
     */
26
    public function run()
27
    {
28
        // read the template file
29
        $this->headerMarkdownContent = file_get_contents(app_path(self::TEMPLATE_PATH . 'header.template.md'));
30
31
        $this->replace('api.domain.dev', Config::get('api.domain'));
32
        $this->replace('{{rate-limit-expires}}', Config::get('hello.api.limit_expires'));
33
        $this->replace('{{rate-limit}}', Config::get('hello.api.limit'));
34
        $this->replace('{{token-expires}}', $this->minutesToTimeDisplay(Config::get('jwt.ttl')));
35
        $this->replace('{{token-expires-minutes}}', Config::get('jwt.ttl'));
36
        $this->replace('{{pagination-limit}}', Config::get('repository.pagination.limit'));
37
38
        // write the actual file
39
        file_put_contents(public_path(self::OUTPUT_PATH . 'header.md'), $this->headerMarkdownContent);
40
    }
41
42
}
43