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

ProcessMarkdownTemplatesTask::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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