Skip to content

Commit ea72a0a

Browse files
authored
Merge pull request #9 from JBlond/development
tabs vs space
2 parents ab6e491 + f326877 commit ea72a0a

File tree

12 files changed

+1635
-1630
lines changed

12 files changed

+1635
-1630
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_size = 4
8+
indent_style = space

lib/Autoloader.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
class Autoloader
99
{
1010

11-
/**
12-
* Autoloader constructor.
13-
*/
14-
public function __construct()
15-
{
16-
spl_autoload_register(array($this, '__autoload'));
17-
}
11+
/**
12+
* Autoloader constructor.
13+
*/
14+
public function __construct()
15+
{
16+
spl_autoload_register(array($this, '__autoload'));
17+
}
1818

19-
/**
20-
* @param string $class
21-
*/
22-
private function __autoload($class)
23-
{
24-
$class = str_replace('\\', '/', $class); // revert path for old PHP on Linux
25-
$dir = str_replace('\\', '/', __DIR__);
26-
if (file_exists($dir . '/' . $class . '.php')) {
27-
/** @noinspection PhpIncludeInspection */
28-
require_once $dir . '/' . $class . '.php';
29-
}
30-
}
19+
/**
20+
* @param string $class
21+
*/
22+
private function __autoload($class)
23+
{
24+
$class = str_replace('\\', '/', $class); // revert path for old PHP on Linux
25+
$dir = str_replace('\\', '/', __DIR__);
26+
if (file_exists($dir . '/' . $class . '.php')) {
27+
/** @noinspection PhpIncludeInspection */
28+
require_once $dir . '/' . $class . '.php';
29+
}
30+
}
3131
}

lib/jblond/Diff.php

Lines changed: 131 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -49,135 +49,135 @@
4949
*/
5050
class Diff
5151
{
52-
/**
53-
* @var array The "old" sequence to use as the basis for the comparison.
54-
*/
55-
private $a = null;
56-
57-
/**
58-
* @var array The "new" sequence to generate the changes for.
59-
*/
60-
private $b = null;
61-
62-
/**
63-
* @var array Array containing the generated op codes for the differences between the two items.
64-
*/
65-
private $groupedCodes = null;
66-
67-
/**
68-
* @var array Associative array of the default options available for the diff class and their default value.
69-
*/
70-
private $defaultOptions = array(
71-
'context' => 3,
72-
'ignoreNewLines' => false,
73-
'ignoreWhitespace' => false,
74-
'ignoreCase' => false,
75-
'labelDifferences'=>'Differences'
76-
);
77-
78-
/**
79-
* @var array Array of the options that have been applied for generating the diff.
80-
*/
81-
public $options = array();
82-
83-
/**
84-
* The constructor.
85-
*
86-
* @param array $a Array containing the lines of the first string to compare.
87-
* @param array $b Array containing the lines for the second string to compare.
88-
* @param array $options Array for the options
89-
*/
90-
public function __construct($a, $b, $options = array())
91-
{
92-
$this->a = $a;
93-
$this->b = $b;
94-
95-
if (is_array($options)) {
96-
$this->options = array_merge($this->defaultOptions, $options);
97-
} else {
98-
$this->options = $this->defaultOptions;
99-
}
100-
}
101-
102-
103-
/**
104-
* Render a diff using the supplied rendering class and return it.
105-
*
106-
* @param object $renderer object $renderer An instance of the rendering object to use for generating the diff.
107-
* @return mixed The generated diff. Exact return value depends on the rendered.
108-
*/
109-
public function render($renderer)
110-
{
111-
$renderer->diff = $this;
112-
return $renderer->render();
113-
}
114-
115-
/**
116-
* Get a range of lines from $start to $end from the first comparison string
117-
* and return them as an array. If no values are supplied, the entire string
118-
* is returned. It's also possible to specify just one line to return only
119-
* that line.
120-
*
121-
* @param int $start The starting number.
122-
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
123-
* @return array Array of all of the lines between the specified range.
124-
*/
125-
public function getA($start = 0, $end = null) : array
126-
{
127-
if ($start == 0 && $end === null) {
128-
return $this->a;
129-
}
130-
131-
if ($end === null) {
132-
$length = 1;
133-
} else {
134-
$length = $end - $start;
135-
}
136-
137-
return array_slice($this->a, $start, $length);
138-
}
139-
140-
/**
141-
* Get a range of lines from $start to $end from the second comparison string
142-
* and return them as an array. If no values are supplied, the entire string
143-
* is returned. It's also possible to specify just one line to return only
144-
* that line.
145-
*
146-
* @param int $start The starting number.
147-
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
148-
* @return array Array of all of the lines between the specified range.
149-
*/
150-
public function getB($start = 0, $end = null) : array
151-
{
152-
if ($start == 0 && $end === null) {
153-
return $this->b;
154-
}
155-
156-
if ($end === null) {
157-
$length = 1;
158-
} else {
159-
$length = $end - $start;
160-
}
161-
162-
return array_slice($this->b, $start, $length);
163-
}
164-
165-
/**
166-
* Generate a list of the compiled and grouped op codes for the differences between the
167-
* two strings. Generally called by the renderer, this class instantiates the sequence
168-
* matcher and performs the actual diff generation and return an array of the op codes
169-
* for it. Once generated, the results are cached in the diff class instance.
170-
*
171-
* @return array Array of the grouped op codes for the generated diff.
172-
*/
173-
public function getGroupedOpcodes() : array
174-
{
175-
if (!is_null($this->groupedCodes)) {
176-
return $this->groupedCodes;
177-
}
178-
179-
$sequenceMatcher = new SequenceMatcher($this->a, $this->b, $this->options, null);
180-
$this->groupedCodes = $sequenceMatcher->getGroupedOpcodes($this->options['context']);
181-
return $this->groupedCodes;
182-
}
52+
/**
53+
* @var array The "old" sequence to use as the basis for the comparison.
54+
*/
55+
private $a = null;
56+
57+
/**
58+
* @var array The "new" sequence to generate the changes for.
59+
*/
60+
private $b = null;
61+
62+
/**
63+
* @var array Array containing the generated op codes for the differences between the two items.
64+
*/
65+
private $groupedCodes = null;
66+
67+
/**
68+
* @var array Associative array of the default options available for the diff class and their default value.
69+
*/
70+
private $defaultOptions = array(
71+
'context' => 3,
72+
'ignoreNewLines' => false,
73+
'ignoreWhitespace' => false,
74+
'ignoreCase' => false,
75+
'labelDifferences'=>'Differences'
76+
);
77+
78+
/**
79+
* @var array Array of the options that have been applied for generating the diff.
80+
*/
81+
public $options = array();
82+
83+
/**
84+
* The constructor.
85+
*
86+
* @param array $a Array containing the lines of the first string to compare.
87+
* @param array $b Array containing the lines for the second string to compare.
88+
* @param array $options Array for the options
89+
*/
90+
public function __construct($a, $b, $options = array())
91+
{
92+
$this->a = $a;
93+
$this->b = $b;
94+
95+
if (is_array($options)) {
96+
$this->options = array_merge($this->defaultOptions, $options);
97+
} else {
98+
$this->options = $this->defaultOptions;
99+
}
100+
}
101+
102+
103+
/**
104+
* Render a diff using the supplied rendering class and return it.
105+
*
106+
* @param object $renderer object $renderer An instance of the rendering object to use for generating the diff.
107+
* @return mixed The generated diff. Exact return value depends on the rendered.
108+
*/
109+
public function render($renderer)
110+
{
111+
$renderer->diff = $this;
112+
return $renderer->render();
113+
}
114+
115+
/**
116+
* Get a range of lines from $start to $end from the first comparison string
117+
* and return them as an array. If no values are supplied, the entire string
118+
* is returned. It's also possible to specify just one line to return only
119+
* that line.
120+
*
121+
* @param int $start The starting number.
122+
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
123+
* @return array Array of all of the lines between the specified range.
124+
*/
125+
public function getA($start = 0, $end = null) : array
126+
{
127+
if ($start == 0 && $end === null) {
128+
return $this->a;
129+
}
130+
131+
if ($end === null) {
132+
$length = 1;
133+
} else {
134+
$length = $end - $start;
135+
}
136+
137+
return array_slice($this->a, $start, $length);
138+
}
139+
140+
/**
141+
* Get a range of lines from $start to $end from the second comparison string
142+
* and return them as an array. If no values are supplied, the entire string
143+
* is returned. It's also possible to specify just one line to return only
144+
* that line.
145+
*
146+
* @param int $start The starting number.
147+
* @param int $end The ending number. If not supplied, only the item in $start will be returned.
148+
* @return array Array of all of the lines between the specified range.
149+
*/
150+
public function getB($start = 0, $end = null) : array
151+
{
152+
if ($start == 0 && $end === null) {
153+
return $this->b;
154+
}
155+
156+
if ($end === null) {
157+
$length = 1;
158+
} else {
159+
$length = $end - $start;
160+
}
161+
162+
return array_slice($this->b, $start, $length);
163+
}
164+
165+
/**
166+
* Generate a list of the compiled and grouped op codes for the differences between the
167+
* two strings. Generally called by the renderer, this class instantiates the sequence
168+
* matcher and performs the actual diff generation and return an array of the op codes
169+
* for it. Once generated, the results are cached in the diff class instance.
170+
*
171+
* @return array Array of the grouped op codes for the generated diff.
172+
*/
173+
public function getGroupedOpcodes() : array
174+
{
175+
if (!is_null($this->groupedCodes)) {
176+
return $this->groupedCodes;
177+
}
178+
179+
$sequenceMatcher = new SequenceMatcher($this->a, $this->b, $this->options, null);
180+
$this->groupedCodes = $sequenceMatcher->getGroupedOpcodes($this->options['context']);
181+
return $this->groupedCodes;
182+
}
183183
}

0 commit comments

Comments
 (0)