Passed
Pull Request — master (#1375)
by Richard
08:11
created

Smarty3RepairOutput   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 95
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A makeOutputIssue() 0 6 1
A __construct() 0 4 1
A outputAppend() 0 3 1
A outputWrapUp() 0 3 1
A outputStart() 0 6 1
A outputFetch() 0 3 1
A addToCount() 0 3 1
A outputIssue() 0 7 1
1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
namespace Xoops\Upgrade;
13
14
use ArrayObject;
15
16
/**
17
 * XOOPS Upgrade Smarty3RepairOutput
18
 *
19
 * Used to report Smarty3 issues corrected in migration fixes
20
 *
21
 * @category  Xoops\Upgrade
22
 * @package   Xoops
23
 * @author    Richard Griffith <[email protected]>
24
 * @copyright 2023 XOOPS Project (https://xoops.org)
25
 * @license   GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
26
 * @link      https://xoops.org
27
 */
28
class Smarty3RepairOutput extends ScannerOutput
29
{
30
    /**
31
     * @var string $content accumulated output
32
     */
33
    protected $content = '';
34
35
    /**
36
     * @var int $issueCounts
37
     */
38
    protected $issueCounts;
39
40
    /**
41
     * Initialize
42
     */
43
    public function __construct()
44
    {
45
        $this->content = '';
46
        $this->issueCounts = 0;
47
    }
48
49
    /**
50
     * add to count of fixed issues
51
     *
52
     * @param int $count
53
     *
54
     * @return void
55
     */
56
    public function addToCount($count)
57
    {
58
        $this->issueCounts += $count;
59
    }
60
61
    /**
62
     * Return recorded output
63
     *
64
     * @returns string
65
     */
66
    public function outputFetch()
67
    {
68
        return $this->content;
69
    }
70
71
    /**
72
     * Add item to report
73
     *
74
     * @param string $item
75
     *
76
     * @return void
77
     */
78
    public function outputAppend($item)
79
    {
80
        $this->content .= $item . "\n";
81
    }
82
83
    /**
84
     * Called to
85
     */
86
    public function outputStart()
87
    {
88
        $this->outputAppend('<h2>' . _XOOPS_SMARTY3_SCANNER_RESULTS . '</h2>');
89
        $this->outputAppend('<table class="table"><tr><th>'
90
            . _XOOPS_SMARTY3_SCANNER_FILE . '</th><th>'
91
            . _XOOPS_SMARTY3_SCANNER_FIXED . '</th></tr>');
92
    }
93
94
    public function outputWrapUp()
95
    {
96
        $this->outputAppend('</table>');
97
    }
98
99
    /**
100
     * @param ArrayObject $args should contain these keys: filename, count
101
     */
102
    public function outputIssue(ArrayObject $args)
103
    {
104
        $filename = $args['filename'];
105
        $count  = $args['count'];
106
        $this->outputAppend("<tr><td>{$filename}</td><td>{$count}</td></tr>");
107
108
        $this->addToCount($count);
109
    }
110
111
    /**
112
     * @param string $filename
113
     * @param int $count
114
     *
115
     * @returns ArrayObject with keys 'filename', 'count'
116
     */
117
    public function makeOutputIssue($filename, $count)
118
    {
119
        return new ArrayObject(
120
            array(
121
                'filename' => $filename,
122
                'count' => $count
123
            )
124
        );
125
    }
126
}
127
//$output->outputIssue($output->makeOutputIssue($filename, $count));
128