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

The-oGlow / ya-corapi / 19973072714

05 Dec 2025 07:00PM UTC coverage: 37.825%. First build
19973072714

push

github

web-flow
Push2master (#4)

11 of 51 new or added lines in 13 files covered. (21.57%)

713 of 1885 relevant lines covered (37.82%)

1.88 hits per line

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

0.0
/src/Yacorapi/Helper/BatchTaskHelper.php
1
<?php
2

3
// phpcs:ignoreFile
4
declare(strict_types=1);
5

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

15
namespace oglowa\tools\Yacorapi\Helper;
16

17
use Ds\Map;
18
use Monolog\ConsoleLogger;
19
use oglowa\tools\Yacorapi\ConstData;
20
use Psr\Log\LoggerInterface;
21

22
class BatchTaskHelper extends AbstractHelper
23
{
24
    public const DEFAULT = 'DEFAULT';
25

26
    /** @var TaskList<Task>[] */
27
    private $tasklist = [];
28

29
    /** @var LoggerInterface */
30
    private static $logger;
31

32
    public function __construct(bool $withLogger = true)
×
33
    {
NEW
34
        self::$logger = new ConsoleLogger(BatchTaskHelper::class);
×
35
        self::$logger->debug('START');
×
36

37
        parent::__construct(BatchTaskHelper::class, $withLogger);
×
38

39
        self::$logger->debug('END');
×
40
    }
41

42
    public function getTaskList(string $key = self::DEFAULT): TaskList
×
43
    {
44
        if ($key !== $this->tasklist->getKey()) {
×
45
            $this->tasklist[$key] = new TaskList($key);
×
46
        }
47

48
        return $this->tasklist[$key];
×
49
    }
50

51
    /**
52
     * @param string $key
53
     *
54
     * @return TaskList<Task>
55
     */
56
    public function readResultFile(string $key = self::DEFAULT)
×
57
    {
58
        $constData = new ConstData(get_class($this));
×
NEW
59
        $fileName  = sprintf(
×
NEW
60
            '%s%s%s',
×
NEW
61
            $constData->prepareFinalTarget($this->constData->c(ConstData::KEY_INPUT_DIR), __CLASS__),
×
NEW
62
            DIRECTORY_SEPARATOR,
×
NEW
63
            $key
×
NEW
64
        );
×
65

66
        if (file_exists($fileName)) {
×
67
            $taskList = $this->getTaskList($key);
×
68
            $fHandle  = fopen($fileName, 'r');
×
69
            if (is_resource($fHandle)) {
×
70
                //                $idx = 0;
71
                //                while ($line = fgets($fHandle, 1000)) {
72
                //                    $convertedLine = mb_convert_encoding($line, 'UTF-8');
73
                //                    if (is_string($convertedLine)) {
74
                //                        $newLine = preg_filter("/(\r|\n|\r\n)/", '', $convertedLine);
75
                //                        self::$logger->debug('newLine', [$newLine]);
76
                //                        $newTask = null;
77
                //                        if (!empty($newLine)) {
78
                //                            $newTask = new Task($key . $idx++, explode(';', $newLine));
79
                //                        }
80
                //                        self::$logger->debug('newTask', [$newTask]);
81
                //                        if (!empty($newTask)) {
82
                //                            $taskList->push($newTask);
83
                //                        }
84
                //                    }
85
                //                }
86
                fclose($fHandle);
×
87
            }
88
        } else {
89
            self::$logger->warning('File does not exists!', [$fileName]);
×
90
            $taskList = new TaskList($key);
×
91
        }
92

93
        return $taskList;
×
94
    }
95

96
    protected function prepareSettings(): void
×
97
    {
98
        // NothingToDo
99
    }
×
100

NEW
101
    protected function validateSettings(Map $overrideParameters): bool
×
102
    {
103
        return true;
×
104
    }
105
}
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