GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (14)

src/Release.php (1 issue)

Severity
1
<?php
2
3
namespace AlibabaCloud;
4
5
use Composer\Script\Event;
6
7
/**
8
 * Class Release
9
 *
10
 * @codeCoverageIgnore
11
 * @package AlibabaCloud\Client
12
 */
13
class Release
14
{
15
16
    /**
17
     * Version of the SDK
18
     */
19
    const VERSION = '1.8.2123';
20
21
    /**
22
     * @param Event $event
23
     */
24
    public static function release(Event $event)
25
    {
26
        $arguments = $event->getArguments();
27
        if (count($arguments) <= 1) {
28
            die('Missing ChangeLog');
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
29
        }
30
        self::updateChangelogFile($arguments[0], $arguments[1]);
31
        self::changeVersionInCode($arguments[0]);
32
    }
33
34
    /**
35
     * @param $version
36
     * @param $changeLog
37
     */
38
    private static function updateChangelogFile($version, $changeLog)
39
    {
40
        $content = preg_replace(
41
            '/# CHANGELOG/',
42
            '# CHANGELOG'
43
            . "\n"
44
            . "\n"
45
            . "## $version - " . date('Y-m-d')
46
            . self::log($changeLog),
47
            self::getChangeLogContent()
48
        );
49
50
        file_put_contents(self::getChangeLogFile(), $content);
51
    }
52
53
    /**
54
     * @param $changeLog
55
     *
56
     * @return string
57
     */
58
    private static function log($changeLog)
59
    {
60
        $logs   = explode('|', $changeLog);
61
        $string = "\n";
62
        foreach ($logs as $log) {
63
            if ($log) {
64
                $string .= "- $log." . "\n";
65
            }
66
        }
67
68
        return $string;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    private static function getChangeLogContent()
75
    {
76
        return file_get_contents(self::getChangeLogFile());
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    private static function getChangeLogFile()
83
    {
84
        return __DIR__ . '/../CHANGELOG.md';
85
    }
86
87
    /**
88
     * @param $version
89
     */
90
    private static function changeVersionInCode($version)
91
    {
92
        $symbol  = "'";
93
        $content = preg_replace(
94
            "/const VERSION = \'(.*)\';/",
95
            "const VERSION = $symbol$version$symbol;",
96
            self::getCodeContent()
97
        );
98
        file_put_contents(self::getCodeFile(), $content);
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    private static function getCodeContent()
105
    {
106
        return file_get_contents(self::getCodeFile());
107
    }
108
109
    /**
110
     * @return string
111
     */
112
    private static function getCodeFile()
113
    {
114
        return __DIR__ . '/Release.php';
115
    }
116
}
117