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

FileBackup   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A makeBackup() 0 8 2
1
<?php
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2016 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
class FileBackup
9
{
10
  const SUFFIX_DATE_TIME = '.Y-m-d_H-i';
11
12
  public $backupPath;
13
14
  public $suffixFormat;
15
16
  public function __construct($backupPath)
17
  {
18
    $this->backupPath = $backupPath;
19
    $this->suffixFormat = self::SUFFIX_DATE_TIME;
20
  }
21
22
  public function makeBackup($file)
23
  {
24
    $fileName = basename($file);
25
    $fileName .= date($this->suffixFormat);
26
27
    if( !rename($file, $this->backupPath.$fileName) )
28
      throw new ErrorException('Не удалось создать резервную копию файла '.$file);
29
  }
30
}