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.
Completed
Push — master ( 1ba1f4...ea41a5 )
by Alexey
05:37
created

UploadHelper::doCustomFilename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2015 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
class UploadHelper
9
{
10
  /**
11
   * Добавляет случайное число после имени файла
12
   *
13
   * @param string $fileName
14
   *
15
   * @return string
16
   */
17
  public static function doUniqueFilename($fileName)
18
  {
19
    $ext = pathinfo($fileName, PATHINFO_EXTENSION);
20
    $name = pathinfo($fileName, PATHINFO_FILENAME);
21
22
    return $name . '_' . rand(1, 1000) . '.' . $ext;
23
  }
24
25
  /**
26
   * Если файл существует с таким названием уже существует, то создаёт новое имя файла.
27
   *
28
   * @param string $path
29
   * @param string $fileName
30
   *
31
   * @return string
32
   */
33
  public static function prepareFileName($path, $fileName)
34
  {
35
    $ext = pathinfo($fileName, PATHINFO_EXTENSION);
36
    $name = pathinfo($fileName, PATHINFO_FILENAME);
37
38
    $name = Utils::translite($name, true);
39
    $ext = Utils::translite($ext, true);
40
41
    $fileName = $name.'.'.$ext;
42
43
    while( file_exists($path . $fileName) )
44
      $fileName = self::doUniqueFilename($fileName);
45
46
    return $fileName;
47
  }
48
}