@@ -44,6 +44,12 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | class Color { |
| 46 | 46 | public $r, $g, $b; |
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @param integer $r |
|
| 50 | + * @param integer $g |
|
| 51 | + * @param integer $b |
|
| 52 | + */ |
|
| 47 | 53 | public function __construct($r, $g, $b) { |
| 48 | 54 | $this->r = $r; |
| 49 | 55 | $this->g = $g; |
@@ -304,6 +310,7 @@ discard block |
||
| 304 | 310 | * Calculate steps between two Colors |
| 305 | 311 | * @param object Color $steps start color |
| 306 | 312 | * @param object Color $ends end color |
| 313 | + * @param integer $steps |
|
| 307 | 314 | * @return array [r,g,b] steps for each color to go from $steps to $ends |
| 308 | 315 | */ |
| 309 | 316 | private function stepCalc($steps, $ends) { |
@@ -315,8 +322,9 @@ discard block |
||
| 315 | 322 | } |
| 316 | 323 | /** |
| 317 | 324 | * Convert a string to an integer evenly |
| 318 | - * @param string $hash the text to parse |
|
| 319 | - * @param int $maximum the maximum range |
|
| 325 | + * @param integer $steps |
|
| 326 | + * @param Color $color1 |
|
| 327 | + * @param Color $color2 |
|
| 320 | 328 | * @return int between 0 and $maximum |
| 321 | 329 | */ |
| 322 | 330 | private function mixPalette($steps, $color1, $color2) { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * @inheritdoc |
| 93 | 93 | */ |
| 94 | - public function get ($size = 64) { |
|
| 94 | + public function get($size = 64) { |
|
| 95 | 95 | try { |
| 96 | 96 | $file = $this->getFile($size); |
| 97 | 97 | } catch (NotFoundException $e) { |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | * @throws NotSquareException if the image is not square |
| 122 | 122 | * @return void |
| 123 | 123 | */ |
| 124 | - public function set ($data) { |
|
| 124 | + public function set($data) { |
|
| 125 | 125 | |
| 126 | - if($data instanceOf IImage) { |
|
| 126 | + if ($data instanceOf IImage) { |
|
| 127 | 127 | $img = $data; |
| 128 | 128 | $data = $img->data(); |
| 129 | 129 | } else { |
| 130 | 130 | $img = new OC_Image(); |
| 131 | 131 | if (is_resource($data) && get_resource_type($data) === "gd") { |
| 132 | 132 | $img->setResource($data); |
| 133 | - } elseif(is_resource($data)) { |
|
| 133 | + } elseif (is_resource($data)) { |
|
| 134 | 134 | $img->loadFromFileHandle($data); |
| 135 | 135 | } else { |
| 136 | 136 | try { |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | * remove the users avatar |
| 181 | 181 | * @return void |
| 182 | 182 | */ |
| 183 | - public function remove () { |
|
| 183 | + public function remove() { |
|
| 184 | 184 | $avatars = $this->folder->getDirectoryListing(); |
| 185 | 185 | |
| 186 | 186 | $this->config->setUserValue($this->user->getUID(), 'avatar', 'version', |
| 187 | - (int)$this->config->getUserValue($this->user->getUID(), 'avatar', 'version', 0) + 1); |
|
| 187 | + (int) $this->config->getUserValue($this->user->getUID(), 'avatar', 'version', 0) + 1); |
|
| 188 | 188 | |
| 189 | 189 | foreach ($avatars as $avatar) { |
| 190 | 190 | $avatar->delete(); |
@@ -210,9 +210,9 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if ($size === -1) { |
| 213 | - $path = 'avatar.' . $ext; |
|
| 213 | + $path = 'avatar.'.$ext; |
|
| 214 | 214 | } else { |
| 215 | - $path = 'avatar.' . $size . '.' . $ext; |
|
| 215 | + $path = 'avatar.'.$size.'.'.$ext; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | try { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } else { |
| 229 | 229 | $avatar = new OC_Image(); |
| 230 | 230 | /** @var ISimpleFile $file */ |
| 231 | - $file = $this->folder->getFile('avatar.' . $ext); |
|
| 231 | + $file = $this->folder->getFile('avatar.'.$ext); |
|
| 232 | 232 | $avatar->loadFromData($file->getContent()); |
| 233 | 233 | $avatar->resize($size); |
| 234 | 234 | $data = $avatar->data(); |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | $file = $this->folder->newFile($path); |
| 239 | 239 | $file->putContent($data); |
| 240 | 240 | } catch (NotPermittedException $e) { |
| 241 | - $this->logger->error('Failed to save avatar for ' . $this->user->getUID()); |
|
| 241 | + $this->logger->error('Failed to save avatar for '.$this->user->getUID()); |
|
| 242 | 242 | throw new NotFoundException(); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if($this->config->getUserValue($this->user->getUID(), 'avatar', 'generated', null) === null) { |
|
| 247 | + if ($this->config->getUserValue($this->user->getUID(), 'avatar', 'generated', null) === null) { |
|
| 248 | 248 | $generated = $this->folder->fileExists('generated') ? 'true' : 'false'; |
| 249 | 249 | $this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', $generated); |
| 250 | 250 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $white = imagecolorallocate($im, 255, 255, 255); |
| 282 | 282 | imagefilledrectangle($im, 0, 0, $size, $size, $background); |
| 283 | 283 | |
| 284 | - $font = __DIR__ . '/../../core/fonts/OpenSans-Semibold.ttf'; |
|
| 284 | + $font = __DIR__.'/../../core/fonts/OpenSans-Semibold.ttf'; |
|
| 285 | 285 | |
| 286 | 286 | $fontSize = $size * 0.4; |
| 287 | 287 | $box = imagettfbbox($fontSize, 0, $font, $text); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $result = array(); |
| 345 | 345 | |
| 346 | 346 | // Splitting evenly the string |
| 347 | - for ($i=0; $i< strlen($hash); $i++) { |
|
| 347 | + for ($i = 0; $i < strlen($hash); $i++) { |
|
| 348 | 348 | // chars in md5 goes up to f, hex:16 |
| 349 | 349 | $result[] = intval(substr($hash, $i, 1), 16) % 16; |
| 350 | 350 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | $finalPalette = array_merge($palette1, $palette2, $palette3); |
| 382 | 382 | |
| 383 | - return $finalPalette[$this->hashToInt($hash, $steps * 3 )]; |
|
| 383 | + return $finalPalette[$this->hashToInt($hash, $steps * 3)]; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | public function userChanged($feature, $oldValue, $newValue) { |