Completed
Push — master ( 2855be...490a20 )
by Shcherbak
02:34
created

FileContent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 61
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 3 1
A get() 0 3 1
A isChanged() 0 3 1
A getContentHash() 0 3 1
1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommend to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
  namespace Funivan\Cs\FileFinder;
4
5
  /**
6
   *
7
   */
8
  class FileContent {
9
10
    /**
11
     * @var string
12
     */
13
    private $content;
14
15
    /**
16
     * @var boolean
17
     */
18
    private $isChanged = false;
0 ignored issues
show
Unused Code introduced by
The property $isChanged is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
20
    /**
21
     * @var string|null
22
     */
23
    private $initialContentHashSum = null;
24
25
26
    /**
27
     * @param string $content
28
     */
29
    public function __construct($content) {
30
      $this->content = $content;
31
      $this->initialContentHashSum = $this->getContentHash();
32
    }
33
34
35
    /**
36
     * @param string $content
37
     * @void
38
     */
39
    public function set($content) {
40
      $this->content = $content;
41
    }
42
43
44
    /**
45
     * @return string
46
     */
47
    public function get() {
48
      return $this->content;
49
    }
50
51
52
    /**
53
     * @return boolean
54
     */
55
    public function isChanged() {
56
      return ($this->initialContentHashSum !== $this->getContentHash());
57
    }
58
59
60
    /**
61
     * @return string
62
     */
63
    private function getContentHash() {
64
      return md5($this->content);
65
    }
66
67
68
  }