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

daycry / jobs / 24850441053

23 Apr 2026 05:54PM UTC coverage: 52.404% (-1.5%) from 53.938%
24850441053

push

github

daycry
Fixes

104 of 219 new or added lines in 42 files covered. (47.49%)

14 existing lines in 9 files now uncovered.

1210 of 2309 relevant lines covered (52.4%)

4.37 hits per line

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

0.0
/src/Commands/PublishCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Queues.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Jobs\Commands;
15

16
use CodeIgniter\CLI\CLI;
17
use Config\Autoload;
18
use Exception;
19

20
/**
21
 * Publishes package configuration files into the application namespace so they can be customized.
22
 */
23
class PublishCommand extends BaseJobsCommand
24
{
25
    /**
26
     * The Command's name
27
     *
28
     * @var string
29
     */
30
    protected $name = 'jobs:publish';
31

32
    /**
33
     * the Command's short description
34
     *
35
     * @var string
36
     */
37
    protected $description = 'Publish the jobs config file.';
38

39
    /**
40
     * the Command's usage
41
     *
42
     * @var string
43
     */
44
    protected $usage = 'jobs:publish';
45

46
    /**
47
     * Source Path
48
     *
49
     * @var string
50
     */
51
    protected $sourcePath = '';
52

53
    /**
54
     * Assets Path
55
     *
56
     * @var string
57
     */
58
    protected $assetsPath = '';
59

60
    /**
61
     * Enables task running
62
     */
63
    public function run(array $params): void
64
    {
65
        $this->determineSourcePath();
×
66

67
        // Config
68
        if (CLI::prompt('Publish Config file?', ['y', 'n']) === 'y') {
×
69
            $this->publishConfig();
×
70
        }
71

72
        // $this->call('cronjob:assets');
73
    }
74

75
    protected function publishConfig(): void
76
    {
77
        $path = "{$this->sourcePath}/Config/Jobs.php";
×
78

79
        $content = file_get_contents($path);
×
80
        $content = str_replace('namespace Daycry\Jobs\Config', 'namespace Config', $content);
×
81
        $content = str_replace('extends BaseConfig', 'extends \\Daycry\\Jobs\\Config\\Jobs', $content);
×
82

83
        $this->writeFile('Config/Jobs.php', $content);
×
84
    }
85

86
    /**
87
     * Determines the current source path from which all other files are located.
88
     */
89
    protected function determineSourcePath(): void
90
    {
91
        $this->sourcePath = realpath(__DIR__ . '/../');
×
92

NEW
93
        if ($this->sourcePath === '/' || in_array($this->sourcePath, ['', '0', false], true)) {
×
94
            CLI::error('Unable to determine the correct source directory. Bailing.');
×
95

96
            exit();
×
97
        }
98
    }
99

100
    /**
101
     * Write a file, catching any exceptions and showing a
102
     * nicely formatted error.
103
     */
104
    protected function writeFile(string $path, string $content): void
105
    {
106
        $config  = new Autoload();
×
107
        $appPath = $config->psr4[APP_NAMESPACE];
×
108

109
        $directory = dirname($appPath . $path);
×
110

111
        if (! is_dir($directory)) {
×
112
            mkdir($directory);
×
113
        }
114

115
        try {
116
            write_file($appPath . $path, $content);
×
117
        } catch (Exception $e) {
×
118
            $this->showError($e);
×
119

120
            exit();
×
121
        }
122

123
        $path = str_replace($appPath, '', $path);
×
124

125
        CLI::write(CLI::color('  created: ', 'green') . $path);
×
126
    }
127
}
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