Skip to content

Commit 0df472b

Browse files
Add API documentation
1 parent 7844d94 commit 0df472b

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

src/Chunk.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,37 @@
5454
*/
5555
class Chunk
5656
{
57+
/**
58+
* @var int
59+
*/
5760
private $start;
61+
62+
/**
63+
* @var int
64+
*/
5865
private $startRange;
66+
67+
/**
68+
* @var int
69+
*/
5970
private $end;
71+
/**
72+
* @var int
73+
*/
6074
private $endRange;
75+
76+
/**
77+
* @var array
78+
*/
6179
private $lines;
6280

81+
/**
82+
* @param int $start
83+
* @param int $startRange
84+
* @param int $end
85+
* @param int $endRange
86+
* @param array $lines
87+
*/
6388
public function __construct($start = 0, $startRange = 1, $end = 0, $endRange = 1, array $lines = array())
6489
{
6590
$this->start = (int) $start;
@@ -69,31 +94,49 @@ public function __construct($start = 0, $startRange = 1, $end = 0, $endRange = 1
6994
$this->lines = $lines;
7095
}
7196

97+
/**
98+
* @return int
99+
*/
72100
public function getStart()
73101
{
74102
return $this->start;
75103
}
76104

105+
/**
106+
* @return int
107+
*/
77108
public function getStartRange()
78109
{
79110
return $this->startRange;
80111
}
81112

113+
/**
114+
* @return int
115+
*/
82116
public function getEnd()
83117
{
84118
return $this->end;
85119
}
86120

121+
/**
122+
* @return int
123+
*/
87124
public function getEndRange()
88125
{
89126
return $this->endRange;
90127
}
91128

129+
/**
130+
* @return array
131+
*/
92132
public function getLines()
93133
{
94134
return $this->lines;
95135
}
96136

137+
/**
138+
* @param array $lines
139+
*/
97140
public function setLines(array $lines)
98141
{
99142
$this->lines = $lines;

src/Diff.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,60 @@
5454
*/
5555
class Diff
5656
{
57+
/**
58+
* @var string
59+
*/
5760
private $from;
61+
62+
/**
63+
* @var string
64+
*/
5865
private $to;
66+
67+
/**
68+
* @var Chunk[]
69+
*/
5970
private $chunks;
6071

72+
/**
73+
* @param string $from
74+
* @param string $to
75+
* @param Chunk[] $chunks
76+
*/
6177
public function __construct($from, $to, array $chunks = array())
6278
{
6379
$this->from = $from;
6480
$this->to = $to;
6581
$this->chunks = $chunks;
6682
}
6783

84+
/**
85+
* @return string
86+
*/
6887
public function getFrom()
6988
{
7089
return $this->from;
7190
}
7291

92+
/**
93+
* @return string
94+
*/
7395
public function getTo()
7496
{
7597
return $this->to;
7698
}
7799

100+
/**
101+
* @return Chunk[]
102+
*/
78103
public function getChunks()
79104
{
80105
return $this->chunks;
81106
}
82107

108+
/**
109+
* @param Chunk[] $chunks
110+
*/
83111
public function setChunks(array $chunks)
84112
{
85113
$this->chunks = $chunks;

src/Line.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,37 @@ class Line
5858
const REMOVED = 2;
5959
const UNCHANGED = 3;
6060

61+
/**
62+
* @var int
63+
*/
6164
private $type;
65+
66+
/**
67+
* @var string
68+
*/
6269
private $content;
6370

71+
/**
72+
* @param int $type
73+
* @param string $content
74+
*/
6475
public function __construct($type = self::UNCHANGED, $content = null)
6576
{
6677
$this->type = $type;
6778
$this->content = $content;
6879
}
6980

81+
/**
82+
* @return string
83+
*/
7084
public function getContent()
7185
{
7286
return $this->content;
7387
}
7488

89+
/**
90+
* @return int
91+
*/
7592
public function getType()
7693
{
7794
return $this->type;

src/Parser.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
*/
5757
class Parser
5858
{
59+
/**
60+
* @param string $string
61+
* @return Diff[]
62+
*/
5963
public function parse($string)
6064
{
6165
$lines = preg_split('(\r\n|\r|\n)', $string);
@@ -88,6 +92,10 @@ public function parse($string)
8892
return $diffs;
8993
}
9094

95+
/**
96+
* @param Diff $diff
97+
* @param array $lines
98+
*/
9199
private function parseFileDiff(Diff $diff, array $lines)
92100
{
93101
$chunks = array();

0 commit comments

Comments
 (0)