Completed
Push — master ( c60cf3...36f595 )
by Sebastien
07:49
created

HackedFileIgnoreEndingsHasher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A performHash() 0 9 2
A fetchLines() 0 3 1
1
<?php
2
3
namespace Cerbere\Model\Hacked;
4
5
class HackedFileIgnoreEndingsHasher extends HackedFileHasher {
6
  /**
7
   * Ignores file line endings.
8
   * @inheritdoc
9
   */
10
  public function performHash($filename) {
11
    if (!HackedFileGroup::isBinary($filename)) {
12
      $file = file($filename, FILE_IGNORE_NEW_LINES);
13
      return sha1(serialize($file));
14
    }
15
    else {
16
      return sha1_file($filename);
17
    }
18
  }
19
20
  /**
21
   * @inheritdoc
22
   */
23
  public function fetchLines($filename) {
24
    return file($filename, FILE_IGNORE_NEW_LINES);
25
  }
26
}
27