-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiff.class.php
More file actions
74 lines (57 loc) · 1.52 KB
/
Diff.class.php
File metadata and controls
74 lines (57 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Diff, a diff class writen by php
*
* @version 1.0
* @copyright (c) 2013-2014 Monkee
* <https://github.com/monkee/diff>
* @author monkee<[email protected]>
* @date 2013-10-09
*/
class Diff
{
/**
* strings to be compared
*/
protected $string1 = '';
protected $string2 = '';
/**
* basic options
*/
private $opt = array(
'trimRow' => false, //if ignore space at both sides of line
'ignoreEmptyRow' => false, //if ignore empty line
'seperator' => "\n", //line or char
);
private $rows = array();
public function __construct($string1, $string2, $opt = array()){
$this->string1 = $string1;
$this->string2 = $string2;
$this->opt = array_merge($this->opt, $opt);
}
public function compare(){
}
public function formatRows(){
$this->$rows = array(
$this->convertStringToRow($this->string1),
$this->convertStringToRow($this->string2),
);
}
private function convertStringToRow($string){
$rows = array();
foreach(explode($this->opt['seperator'], $string) as $row){
if($this->opt['trimRow']){
$row = trim($row);
}
if($this->opt['ignoreEmptyRow']){
if(empty($row)){
continue;
}
}
$rows[] = $row;
}
return $rows;
}
}
/* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
?>