Completed
Push — master ( 4905bd...af6d05 )
by Andrii
03:36
created

TwigPage::extractData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 14
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 1
crap 6
1
<?php
2
/**
3
 * Yii2 Pages Module
4
 *
5
 * @link      https://github.com/hiqdev/yii2-module-pages
6
 * @package   yii2-module-pages
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\yii2\modules\pages\models;
12
13
use hiqdev\yii2\modules\pages\Module;
14
use Yii;
15
use yii\base\InvalidConfigException;
16
17
class TwigPage extends AbstractPage
18
{
19
    public function render(array $params = [])
20
    {
21
        $path = Module::getInstance()->getLocalPath($this->path);
22
23
        return Yii::$app->getView()->renderFile($path);
24
    }
25
26 View Code Duplication
    public function extractData($path)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $lines = static::getModule()->readArray($path);
29
        $matterLines = $this->getQuoted($lines, '/^{#/', '/#}$/');
30
        if (empty($matterLines)) {
31
            $data = [];
32
            $text = $lines;
33
        } else {
34
            $data = $this->readFrontMatter($matterLines);
35
            $text = array_slice($lines, count($matterLines));
36
        }
37
38
        return [$data, implode("\n", $text)];
39
    }
40
41
}
42