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

FileContent::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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
  }