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.

StringBuilder::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
/**
3
 * @author Nikita Melnikov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package frontend.share.helpers
8
 */
9
class StringBuilder
10
{
11
  /**
12
   * @var string
13
   */
14
  protected $string;
15
16
  /**
17
   * @param $string
18
   */
19 2
  public function __construct($string = '')
20
  {
21 2
    $this->string = $string;
22 2
  }
23
24 1
  public function __toString()
25
  {
26 1
    return $this->string;
27
  }
28
29
  /**
30
   * @return string
31
   */
32 2
  public function get()
33
  {
34 2
    return $this->string;
35
  }
36
37
  /**
38
   * @param string $delimiter
39
   *
40
   * @return array
41
   */
42
  public function explode($delimiter)
43
  {
44
    return explode($delimiter, $this->string);
45
  }
46
47
  /**
48
   * Добавление к строке следующую
49
   *
50
   * @param string $string
51
   * @param null $prefix префикс|символ перед основной строкой
52
   *
53
   * @return StringBuilder
54
   */
55 1
  public function append($string, $prefix = null)
56
  {
57 1
    $this->string .= $prefix.$string;
58 1
    return $this;
59
  }
60
61
  /**
62
   * @param $string
63
   *
64
   * @return StringBuilder
65
   */
66 2
  public function remove($string)
67
  {
68 2
    $this->replace($string, null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69 2
    return $this;
70
  }
71
72
  /**
73
   * @param string $search
74
   * @param string|callable $replace
75
   * @param bool $regexp
76
   *
77
   * @return $this
78
   */
79 2
  public function replace($search, $replace, $regexp = false)
80
  {
81
    if( $regexp )
82 2
    {
83 2
      if( is_callable($replace) )
84 2
      {
85 1
        $this->string = preg_replace_callback($search, $replace, $this->string);
86 1
      }
87
      else
88
      {
89 2
        $this->string = preg_replace($search, $replace, $this->string);
90
      }
91 2
    }
92
    else
93
    {
94 2
      $this->string = str_replace($search, $replace, $this->string);
95
    }
96
97 2
    return $this;
98
  }
99
}