HtmlWriter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 43
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A openWriter() 0 5 1
A addRowToWriter() 0 5 1
A closeWriter() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-exportable-widget project.
5
 * (c) 2amigOS! <http://2amigos.us/>
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace dosamigos\exportable\writers;
11
12
use Box\Spout\Writer\AbstractWriter;
13
use Yii;
14
15
class HtmlWriter extends AbstractWriter
16
{
17
    /**
18
     * @var string the path to the view files
19
     */
20
    protected $viewPath;
21
22
    /**
23
     * HtmlWriter constructor.
24
     */
25
    public function __construct()
26
    {
27
        $this->viewPath = dirname(__FILE__) . '/../views/html';
28
        parent::__construct();
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    protected function openWriter()
35
    {
36
        $header = Yii::$app->view->renderPhpFile($this->viewPath . '/_header.php');
37
        fwrite($this->filePointer, $header);
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    protected function addRowToWriter(array $dataRow, $style)
44
    {
45
        $row = '<tr>' . implode("\n", $dataRow) . '</tr>';
46
        fwrite($this->filePointer, $row);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    protected function closeWriter()
53
    {
54
        $footer = Yii::$app->view->renderPhpFile($this->viewPath . '/_footer.php');
55
        fwrite($this->filePointer, $footer);
56
    }
57
}
58