• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JBZoo / CI-Report-Converter / 8319938202

28 Jan 2024 02:03PM UTC coverage: 94.125%. Remained the same
8319938202

push

github

web-flow
Update version of jbzoo/cli dependency (#49)

1426 of 1515 relevant lines covered (94.13%)

45.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/Converters/AbstractConverter.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - CI-Report-Converter.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/CI-Report-Converter
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\CIReportConverter\Converters;
18

19
use JBZoo\CIReportConverter\Formats\Source\SourceSuite;
20

21
abstract class AbstractConverter
22
{
23
    /** @var string */
24
    public const TYPE = 'abstract';
25

26
    /** @var string */
27
    public const NAME = 'Abstract';
28

29
    protected ?string $rootPath      = null;
30
    protected ?string $rootSuiteName = null;
31
    protected int     $flowId        = 0;
32

33
    /**
34
     * @phan-suppress PhanUnusedPublicMethodParameter
35
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
36
     */
37
    public function toInternal(string $source): SourceSuite
38
    {
39
        throw new Exception('Method "' . __METHOD__ . '" is not available');
×
40
    }
41

42
    /**
43
     * @phan-suppress PhanUnusedPublicMethodParameter
44
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
45
     */
46
    public function fromInternal(SourceSuite $sourceSuite): string
47
    {
48
        throw new Exception('Method "' . __METHOD__ . '" is not available');
×
49
    }
50

51
    public function setRootPath(string $rootPath): self
52
    {
53
        if ($rootPath === '.') {
156✔
54
            $rootPath = \realpath($rootPath);
12✔
55
        }
56

57
        $this->rootPath = $rootPath === false || $rootPath === '' ? null : $rootPath;
156✔
58

59
        return $this;
156✔
60
    }
61

62
    public function setRootSuiteName(?string $rootSuiteName): self
63
    {
64
        $this->rootSuiteName = $rootSuiteName;
60✔
65

66
        return $this;
60✔
67
    }
68

69
    public function setFlowId(int $flowId): self
70
    {
71
        $this->flowId = $flowId;
54✔
72

73
        return $this;
54✔
74
    }
75

76
    protected function cleanFilepath(?string $origPath): string
77
    {
78
        if (
79
            $this->rootPath !== null
174✔
80
            && $this->rootPath !== ''
174✔
81
            && $origPath !== ''
174✔
82
            && $origPath !== null
174✔
83
        ) {
84
            return \str_replace(\rtrim($this->rootPath, '/') . '/', '', $origPath);
144✔
85
        }
86

87
        return (string)$origPath;
42✔
88
    }
89

90
    protected function getFullPath(?string $relFilename): ?string
91
    {
92
        if ($relFilename === '' || $relFilename === null) {
108✔
93
            return null;
×
94
        }
95

96
        $absFilename = \realpath($relFilename);
108✔
97
        if ($absFilename !== false) {
108✔
98
            return $absFilename;
×
99
        }
100

101
        if ($this->rootPath !== null && $this->rootPath !== '') {
108✔
102
            $rootPath    = \rtrim($this->rootPath, '/');
90✔
103
            $relFilename = \ltrim($relFilename, '.');
90✔
104
            $relFilename = \ltrim($relFilename, '/');
90✔
105

106
            $absFilename = \realpath($rootPath . '/' . $relFilename);
90✔
107
            if ($absFilename !== false) {
90✔
108
                return $absFilename;
×
109
            }
110
        }
111

112
        return $relFilename;
108✔
113
    }
114

115
    protected static function getFilePoint(
116
        ?string $filename = null,
117
        null|int|string $line = 0,
118
        null|int|string $column = 0,
119
    ): ?string {
120
        if ($filename === '' || $filename === null) {
108✔
121
            return null;
×
122
        }
123

124
        $printLine = (int)$line > 1 ? ":{$line}" : '';
108✔
125

126
        if ($printLine !== '') {
108✔
127
            $printColumn = (int)$column > 1 ? ":{$column}" : '';
108✔
128
        } else {
129
            $printColumn = '';
6✔
130
        }
131

132
        return $filename . $printLine . $printColumn;
108✔
133
    }
134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc