FileContent::isChanged()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
  namespace Funivan\Cs\Fs;
4
5
  /**
6
   *
7
   */
8
  class FileContent {
9
10
    /**
11
     * @var string
12
     */
13
    private $content;
14
15
16
    /**
17
     * @var string|null
18
     */
19
    private $initialContentHashSum = null;
20
21
22
    /**
23
     * @param string $content
24
     */
25 74
    public function __construct($content) {
26 74
      $this->content = $content;
27 74
      $this->initialContentHashSum = $this->getContentHash();
28 74
    }
29
30
31
    /**
32
     * @param string $content
33
     * @void
34
     */
35 38
    public function set($content) {
36 38
      $this->content = $content;
37 38
    }
38
39
40
    /**
41
     * @return string
42
     */
43 74
    public function get() {
44 74
      return $this->content;
45
    }
46
47
48
    /**
49
     * @return boolean
50
     */
51
    public function isChanged() {
52
      return ($this->initialContentHashSum !== $this->getContentHash());
53
    }
54
55
56
    /**
57
     * @return string
58
     */
59 74
    private function getContentHash() {
60 74
      return md5($this->content);
61
    }
62
63
  }