equal
deleted
inserted
replaced
4 * two sequences of strings. |
4 * two sequences of strings. |
5 * |
5 * |
6 * The original PHP version of this code was written by Geoffrey T. Dairiki |
6 * The original PHP version of this code was written by Geoffrey T. Dairiki |
7 * <dairiki@dairiki.org>, and is used/adapted with his permission. |
7 * <dairiki@dairiki.org>, and is used/adapted with his permission. |
8 * |
8 * |
9 * $Horde: framework/Text_Diff/Diff.php,v 1.26 2008/01/04 10:07:49 jan Exp $ |
|
10 * |
|
11 * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org> |
9 * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org> |
12 * Copyright 2004-2008 The Horde Project (http://www.horde.org/) |
10 * Copyright 2004-2010 The Horde Project (http://www.horde.org/) |
13 * |
11 * |
14 * See the enclosed file COPYING for license information (LGPL). If you did |
12 * See the enclosed file COPYING for license information (LGPL). If you did |
15 * not receive this file, see http://opensource.org/licenses/lgpl-license.php. |
13 * not receive this file, see http://opensource.org/licenses/lgpl-license.php. |
16 * |
14 * |
17 * @package Text_Diff |
15 * @package Text_Diff |
61 * Returns the array of differences. |
59 * Returns the array of differences. |
62 */ |
60 */ |
63 function getDiff() |
61 function getDiff() |
64 { |
62 { |
65 return $this->_edits; |
63 return $this->_edits; |
|
64 } |
|
65 |
|
66 /** |
|
67 * returns the number of new (added) lines in a given diff. |
|
68 * |
|
69 * @since Text_Diff 1.1.0 |
|
70 * |
|
71 * @return integer The number of new lines |
|
72 */ |
|
73 function countAddedLines() |
|
74 { |
|
75 $count = 0; |
|
76 foreach ($this->_edits as $edit) { |
|
77 if (is_a($edit, 'Text_Diff_Op_add') || |
|
78 is_a($edit, 'Text_Diff_Op_change')) { |
|
79 $count += $edit->nfinal(); |
|
80 } |
|
81 } |
|
82 return $count; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Returns the number of deleted (removed) lines in a given diff. |
|
87 * |
|
88 * @since Text_Diff 1.1.0 |
|
89 * |
|
90 * @return integer The number of deleted lines |
|
91 */ |
|
92 function countDeletedLines() |
|
93 { |
|
94 $count = 0; |
|
95 foreach ($this->_edits as $edit) { |
|
96 if (is_a($edit, 'Text_Diff_Op_delete') || |
|
97 is_a($edit, 'Text_Diff_Op_change')) { |
|
98 $count += $edit->norig(); |
|
99 } |
|
100 } |
|
101 return $count; |
66 } |
102 } |
67 |
103 |
68 /** |
104 /** |
69 * Computes a reversed diff. |
105 * Computes a reversed diff. |
70 * |
106 * |