Completed
Push — master ( 438a01...cdd715 )
by Mahmoud
03:47
created

RenderTemplatesTask   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 21 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 RenderTemplatesTask.
11
 *
12
 * @author Mahmoud Zalt <[email protected]>
13
 */
14
class RenderTemplatesTask extends Task
15
{
16
17
    use DocsGeneratorTrait;
18
19
    protected $headerMarkdownContent;
20
21
    const TEMPLATE_PATH = 'Containers/Documentation/ApiDocJs/shared/';
22
    const OUTPUT_PATH = 'api-rendered-markdowns/';
23
24
    /**
25
     * Read the markdown header template and fill it with some real data from the .env file.
26
     */
27
    public function run()
28
    {
29
        // read the template file
30
        $this->headerMarkdownContent = file_get_contents(app_path(self::TEMPLATE_PATH . 'header.template.md'));
31
32
        $this->replace('api.domain.dev', Config::get('api.domain'));
33
        $this->replace('{{rate-limit-expires}}', Config::get('hello.api.limit_expires'));
34
        $this->replace('{{rate-limit}}', Config::get('hello.api.limit'));
35
        $this->replace('{{token-expires}}', $this->minutesToTimeDisplay(Config::get('jwt.ttl')));
36
        $this->replace('{{token-expires-minutes}}', Config::get('jwt.ttl'));
37
        $this->replace('{{pagination-limit}}', Config::get('repository.pagination.limit'));
38
39
        // this is what the apidoc.json file will point to to load the header.md
40
        // example: "filename": "../public/api-rendered-markdowns/header.md"
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
        $path = public_path(self::OUTPUT_PATH . 'header.md');
42
43
        // write the actual file
44
        file_put_contents($path, $this->headerMarkdownContent);
45
46
        return $path;
47
    }
48
49
}
50