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

The-oGlow / ya-corapi / 20730329328

05 Jan 2026 09:54PM UTC coverage: 50.144% (+3.8%) from 46.354%
20730329328

push

github

oglowa
#3: Update files / tested

522 of 537 new or added lines in 20 files covered. (97.21%)

153 existing lines in 8 files now uncovered.

1048 of 2090 relevant lines covered (50.14%)

8.43 hits per line

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

25.71
/src/Yacorapi/Store/CsvFileAdapter.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of ezlogging
7
 *
8
 * (c) 2024 Oliver Glowa, coding.glowa.com
9
 *
10
 * This source file is subject to the Apache-2.0 license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13

14
namespace oglowa\tools\Yacorapi\Store;
15

16
use Monolog\ConsoleLogger;
17
use ollily\Tools\String\ImplodeTrait;
18
use Psr\Log\LoggerInterface;
19

20
class CsvFileAdapter extends FileAdapter
21
{
22
    use ImplodeTrait;
23

24
    /** @var LoggerInterface */
25
    private $logger;
26

27
    public function __construct(string $outputFileName, string $fileSuffix = '', string $customTargetDir = '')
1✔
28
    {
29
        $this->logger = new ConsoleLogger(CsvFileAdapter::class);
1✔
30
        $this->logger->debug("START");
1✔
31

32
        parent::__construct($outputFileName, $fileSuffix, $customTargetDir);
1✔
33

34
        $this->logger->debug('END');
1✔
35
    }
36

UNCOV
37
    protected function flattenDataHeader($dataHeader): string
×
38
    {
UNCOV
39
        $this->logger->debug("START");
×
40

UNCOV
41
        if (is_array($dataHeader)) {
×
42
            $headerCount = count($dataHeader);
×
43
            for ($idx = 0; $idx < $headerCount; $idx++) {
×
44
                $dataHeader[$idx] = '"' . $dataHeader[$idx] . '"';
×
45
            }
46
        }
47

UNCOV
48
        return parent::flattenDataHeader($dataHeader);
×
49
    }
50

51
    /**
52
     * @param mixed[]|string $param
53
     *
54
     * @return string
55
     */
UNCOV
56
    protected function prepareCsvLine($param): string
×
57
    {
UNCOV
58
        $this->logger->debug("START");
×
59

UNCOV
60
        if (!is_array($param)) {
×
61
            $param = [$param];
×
62
        }
63

UNCOV
64
        return implode(self::C_ITEM_SEP, $param);
×
65
    }
66

67
    /**
68
     * @param string $customTargetDir
69
     * @param string $outputFileName
70
     * @param string $fileExtension
71
     * @param string $storeItemClazz
72
     * @param string $methodName
73
     *
74
     * @return IStoreItem
75
     */
76
    protected function invokeStoreItem(
1✔
77
        string $customTargetDir,
78
        string $outputFileName,
79
        string $fileExtension = IStoreItem::EXT_CSV,
80
        string $storeItemClazz = FileStoreItem::class,
81
        string $methodName = 'prepareTargetFile'
82
    ): IStoreItem {
83
        $this->logger->debug("START");
1✔
84

85
        if (!str_ends_with($fileExtension, IStoreItem::EXT_CSV)) {
1✔
UNCOV
86
            $fileExtension = $fileExtension . '.' . IStoreItem::EXT_CSV;
×
87
        }
88

89
        return parent::invokeStoreItem($customTargetDir, $outputFileName, $fileExtension, $storeItemClazz, $methodName);
1✔
90
    }
91

92
    /**
93
     * @param mixed $dataContent
94
     */
UNCOV
95
    public function storeData($dataContent): void
×
96
    {
UNCOV
97
        $this->logger->debug('START');
×
98
        $this->logger->debug('dataContent', [$dataContent]);
×
99

UNCOV
100
        if (!is_null($dataContent)) {
×
101
            $csvLine = $this->implode_recursive(self::C_ITEM_SEP, $dataContent, false, false);
×
102
            $csvLine = str_replace(self::C_ITEM_SEP . '[', self::C_ITEM_SEP . "\n[", $csvLine);
×
103
            $this->writeData($this->storeItem, $csvLine);
×
104
        }
105

UNCOV
106
        $this->logger->debug('END');
×
107
    }
108

109
    /**
110
     * @param string|string[] $dataHeader
111
     */
UNCOV
112
    public function storeDataHeader($dataHeader): void
×
113
    {
UNCOV
114
        $this->logger->debug("START");
×
115

UNCOV
116
        if (!empty($dataHeader)) {
×
117
            $this->writeData($this->storeItem, $this->flattenDataHeader($dataHeader));
×
118
        }
119

UNCOV
120
        $this->logger->debug('END');
×
121
    }
122
}
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

© 2026 Coveralls, Inc