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

ConsoleFileLogger   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A log() 0 7 2
A warning() 0 7 2
A error() 0 8 2
A flush() 0 4 1
A __destruct() 0 4 1
A onFlush() 0 4 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 ConsoleFileLogger extends CFileLogRoute
9
{
10
  public $showLog = true;
11
12
  /**
13
   * @var CFileLogRoute $logger
14
   */
15
  private $logger;
16
17
  public function __construct($fileName)
18
  {
19
    $this->logger = new CLogger();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \CLogger() of type object<CLogger> is incompatible with the declared type object<CFileLogRoute> of property $logger.

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..

Loading history...
20
    $this->logger->autoFlush = 20;
21
    $this->logger->attachEventHandler('onFlush', array($this, 'onFlush'));
22
23
    $this->setLogFile($fileName);
24
    $this->init();
25
  }
26
27
  /**
28
   * @param string $message
29
   */
30
  public function log($message)
31
  {
32
    $this->logger->log($message, 'info', 'console');
33
34
    if( $this->showLog )
35
      echo $message.PHP_EOL;
36
  }
37
38
  /**
39
   * @param string $message
40
   */
41
  public function warning($message)
42
  {
43
    $this->logger->log($message, 'warning', 'console');
44
45
    if( $this->showLog )
46
      echo $message.PHP_EOL;
47
  }
48
49
  /**
50
   * @param string $message
51
   */
52
  public function error($message)
53
  {
54
    $this->logger->log($message, 'error', 'console');
55
    $this->logger->flush();
56
57
    if( $this->showLog )
58
      echo $message.PHP_EOL;
59
  }
60
61
  /**
62
   * Сохраняет лог в файл с очисткой сообщений из памяти
63
   */
64
  public function flush()
65
  {
66
    $this->logger->flush();
67
  }
68
69
  public function __destruct()
70
  {
71
    $this->logger->flush();
72
  }
73
74
  /**
75
   * Сохраняет лог в файл, сообщения остаются в памяти при прямом вызове метода
76
   */
77
  public function onFlush()
78
  {
79
    $this->collectLogs($this->logger, true);
80
  }
81
}