allejo /
PhpPulse
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * @copyright 2017 Vladimir Jimenez |
||
| 5 | * @license https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace allejo\DaPulse\Objects; |
||
| 9 | |||
| 10 | use allejo\DaPulse\Exceptions\ColumnNotFoundException; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class PulseColumnColorValue |
||
| 14 | * |
||
| 15 | * @package allejo\DaPulse\Objects |
||
| 16 | * @since 0.1.0 |
||
| 17 | */ |
||
| 18 | class PulseColumnStatusValue extends PulseColumnValue |
||
| 19 | { |
||
| 20 | const DEFAULT_VALUE = self::Grey; // The default color for DaPulse columns |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The numerical value of the orange status |
||
| 24 | */ |
||
| 25 | const Orange = 0; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * The numerical value of the light green status |
||
| 29 | */ |
||
| 30 | const L_Green = 1; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * The numerical value of the red status |
||
| 34 | */ |
||
| 35 | const Red = 2; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * The numerical value of the blue status |
||
| 39 | */ |
||
| 40 | const Blue = 3; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * The numerical value of the purple status |
||
| 44 | */ |
||
| 45 | const Purple = 4; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * The numerical value of the grey status |
||
| 49 | */ |
||
| 50 | const Grey = 5; |
||
| 51 | const Gray = self::Grey; // just an alias |
||
| 52 | |||
| 53 | /** |
||
| 54 | * The numerical value of the green status |
||
| 55 | */ |
||
| 56 | const Green = 6; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * The numerical value of the light blue status |
||
| 60 | */ |
||
| 61 | const L_Blue = 7; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * The numerical value of the gold status |
||
| 65 | */ |
||
| 66 | const Gold = 8; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * The numerical value of the yellow status |
||
| 70 | */ |
||
| 71 | const Yellow = 9; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * The numerical value of the black status |
||
| 75 | */ |
||
| 76 | const Black = 10; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * The numerical value of the dark red status |
||
| 80 | */ |
||
| 81 | const D_Red = 11; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * The numerical value of the hot pink status |
||
| 85 | */ |
||
| 86 | const Hot_Pink = 12; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * The numerical value of the pink status |
||
| 90 | */ |
||
| 91 | const Pink = 13; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * The numerical value of the dark purple status |
||
| 95 | */ |
||
| 96 | const D_Purple = 14; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The numerical value of the lime status |
||
| 100 | */ |
||
| 101 | const Lime = 15; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * The numerical value of the cyan status |
||
| 105 | */ |
||
| 106 | const Cyan = 16; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * The numerical value of the dark grey status |
||
| 110 | */ |
||
| 111 | const D_Grey = 17; |
||
| 112 | const D_Gray = self::D_Grey; // another alias |
||
| 113 | |||
| 114 | /** |
||
| 115 | * The numerical value of the brown status |
||
| 116 | */ |
||
| 117 | const Brown = 18; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * The numerical value of the dark orange status |
||
| 121 | */ |
||
| 122 | const D_Orange = 19; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * The lowest status value that exists |
||
| 126 | */ |
||
| 127 | const MIN_VALUE = self::Orange; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * The largest status value that exists |
||
| 131 | */ |
||
| 132 | const MAX_VALUE = self::D_Orange; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Get the numerical representation of the color that a status column is set to. |
||
| 136 | * |
||
| 137 | * @api |
||
| 138 | * |
||
| 139 | * @since 0.4.0 ColumnNotFoundException is now thrown |
||
| 140 | * @since 0.1.0 |
||
| 141 | * |
||
| 142 | * @throws ColumnNotFoundException The specified column ID does not exist for the parent Pulse |
||
| 143 | * |
||
| 144 | * @return int The color value of a column |
||
| 145 | */ |
||
| 146 | 2 | public function getValue () |
|
| 147 | { |
||
| 148 | 2 | return parent::getValue(); |
|
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Update the status of a status column |
||
| 153 | * |
||
| 154 | * It is highly recommended that you use the constants available in the **PulseColumnColorValue** class to match the |
||
| 155 | * colors; keep in mind this value cannot be higher than 19. |
||
| 156 | * |
||
| 157 | * @api |
||
| 158 | * |
||
| 159 | * @param int $color The numerical value of the new color value |
||
| 160 | * |
||
| 161 | * @see PulseColumnStatusValue::Orange |
||
| 162 | * @see PulseColumnStatusValue::L_Green |
||
| 163 | * @see PulseColumnStatusValue::Red |
||
| 164 | * @see PulseColumnStatusValue::Blue |
||
| 165 | * @see PulseColumnStatusValue::Purple |
||
| 166 | * @see PulseColumnStatusValue::Grey |
||
| 167 | * @see PulseColumnStatusValue::Green |
||
| 168 | * @see PulseColumnStatusValue::L_Blue |
||
| 169 | * @see PulseColumnStatusValue::Gold |
||
| 170 | * @see PulseColumnStatusValue::Yellow |
||
| 171 | * @see PulseColumnStatusValue::Black |
||
| 172 | * @see PulseColumnStatusValue::D_Red |
||
| 173 | * @see PulseColumnStatusValue::Hot_Pink |
||
| 174 | * @see PulseColumnStatusValue::Pink |
||
| 175 | * @see PulseColumnStatusValue::D_Purple |
||
| 176 | * @see PulseColumnStatusValue::Lime |
||
| 177 | * @see PulseColumnStatusValue::Cyan |
||
| 178 | * @see PulseColumnStatusValue::D_Grey |
||
| 179 | * @see PulseColumnStatusValue::Brown |
||
| 180 | * @see PulseColumnStatusValue::D_Orange |
||
| 181 | * |
||
| 182 | * @since 0.1.0 |
||
| 183 | * |
||
| 184 | * @throws \InvalidArgumentException if the $color is not an int or is not between 0-19 |
||
| 185 | */ |
||
| 186 | 5 | public function updateValue ($color) |
|
| 187 | { |
||
| 188 | 5 | if ($color < self::MIN_VALUE || $color > self::MAX_VALUE || !is_int($color)) |
|
| 189 | { |
||
| 190 | 4 | throw new \InvalidArgumentException("DaPulse only has color indexes from 0-10"); |
|
| 191 | } |
||
| 192 | |||
| 193 | 1 | $url = sprintf("%s/%d/columns/%s/status.json", self::apiEndpoint(), $this->board_id, $this->column_id); |
|
| 194 | $postParams = [ |
||
| 195 | 1 | "pulse_id" => $this->pulse_id, |
|
| 196 | 1 | "color_index" => $color |
|
| 197 | ]; |
||
| 198 | |||
| 199 | 1 | $result = self::sendPut($url, $postParams); |
|
| 200 | 1 | $this->jsonResponse = $result; |
|
|
0 ignored issues
–
show
|
|||
| 201 | 1 | $this->setValue($result); |
|
| 202 | 1 | } |
|
| 203 | |||
| 204 | /** |
||
| 205 | * Get the hex value of the color used on DaPulse to represent the different statuses. |
||
| 206 | * |
||
| 207 | * @api |
||
| 208 | * |
||
| 209 | * @param int $numericalValue The numerical value of the column |
||
| 210 | * |
||
| 211 | * @since 0.1.0 |
||
| 212 | * |
||
| 213 | * @return string A hex value **without** the leading # |
||
| 214 | */ |
||
| 215 | public static function getHexColor ($numericalValue) |
||
| 216 | { |
||
| 217 | $colorArray = self::getHexColors(); |
||
| 218 | |||
| 219 | return $colorArray[$numericalValue]; |
||
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Get an array of hex values for each of the statuses |
||
| 224 | * |
||
| 225 | * @api |
||
| 226 | * |
||
| 227 | * @since 0.3.1 |
||
| 228 | * |
||
| 229 | * @return array |
||
|
0 ignored issues
–
show
|
|||
| 230 | */ |
||
| 231 | public static function getHexColors () |
||
| 232 | { |
||
| 233 | return [ |
||
| 234 | self::Orange => 'fdab3d', |
||
| 235 | self::L_Green => '00c875', |
||
| 236 | self::Red => 'e2445c', |
||
| 237 | self::Blue => '0086c0', |
||
| 238 | self::L_Blue => '579bfc', |
||
| 239 | self::Purple => 'a25ddc', |
||
| 240 | self::Green => '037f4c', |
||
| 241 | self::Gold => 'CAB641', |
||
| 242 | self::Yellow => 'FFCB00', |
||
| 243 | self::Black => '333333', |
||
| 244 | self::Grey => 'c4c4c4', |
||
| 245 | self::D_Red => 'bb3354', |
||
| 246 | self::Hot_Pink => 'ff158a', |
||
| 247 | self::Pink => 'ff5ac4', |
||
| 248 | self::D_Purple => '784bd1', |
||
| 249 | self::Lime => '9cd326', |
||
| 250 | self::Cyan => '66ccff', |
||
| 251 | self::D_Grey => '808080', |
||
| 252 | self::Brown => '7f5347', |
||
| 253 | self::D_Orange => 'ff642e', |
||
| 254 | ]; |
||
| 255 | } |
||
| 256 | |||
| 257 | 2 | protected function setValue ($response) |
|
| 258 | { |
||
| 259 | 2 | $value = $response['value']; |
|
| 260 | |||
| 261 | // If the status column is set to 'Grey' or the default 'Just Assigned' value, DaPulse will evidently |
||
| 262 | // return null... So let's set it to the Grey value to not confuse people |
||
| 263 | 2 | $this->column_value = (is_array($value) && array_key_exists('index', $value)) ? $response["value"]["index"] : self::Grey; |
|
| 264 | 2 | } |
|
| 265 | } |
||
| 266 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..