forked from php-coveralls/php-coveralls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RequirementsNotSatisfiedException.php
128 lines (104 loc) · 2.37 KB
/
RequirementsNotSatisfiedException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace PhpCoveralls\Bundle\CoverallsBundle\Entity\Exception;
/**
* Requirements of json_file are not satisfied.
*
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
*/
class RequirementsNotSatisfiedException extends \RuntimeException
{
/**
* Error message.
*
* @var string
*/
protected $message = 'Requirements are not satisfied.';
/**
* Read environment variables.
*
* @var array
*/
protected $readEnv;
/**
* Array of secret env vars.
*
* @var string[]
*/
private static $secretEnvVars = [
'COVERALLS_REPO_TOKEN',
];
/**
* Return help message.
*
* @return string
*/
public function getHelpMessage()
{
$message = $this->message . "\n";
if (is_array($this->readEnv)) {
foreach ($this->readEnv as $envVarName => $value) {
$message .= $this->format($envVarName, $value);
}
}
$message .= <<< 'EOL'
Set environment variables properly like the following.
For Travis users:
- TRAVIS
- TRAVIS_JOB_ID
For CircleCI users:
- CIRCLECI
- CIRCLE_BUILD_NUM
- COVERALLS_REPO_TOKEN
For Jenkins users:
- JENKINS_URL
- BUILD_NUMBER
- COVERALLS_REPO_TOKEN
For AppVeyor users:
- APPVEYOR
- APPVEYOR_BUILD_NUMBER
For Githib Actions users:
- GITHUB_REF
- GITHUB_SHA
- GITHUB_ACTIONS
From local environment:
- COVERALLS_RUN_LOCALLY
- COVERALLS_REPO_TOKEN
EOL;
return $message;
}
/**
* Set read environment variables.
*
* @param array $readEnv read environment variables
*/
public function setReadEnv(array $readEnv)
{
$this->readEnv = $readEnv;
}
/**
* Return read environment variables.
*
* @return array
*/
public function getReadEnv()
{
return $this->readEnv;
}
/**
* Format a pair of the envVarName and the value.
*
* @param string $key the env var name
* @param string $value the value of the env var
*
* @return string
*/
protected function format($key, $value)
{
if (in_array($key, self::$secretEnvVars, true)
&& is_string($value)
&& strlen($value) > 0) {
$value = '********(HIDDEN)';
}
return sprintf(" - %s=%s\n", $key, var_export($value, true));
}
}