Skip to content

Commit fc48d18

Browse files
committed
Merge branch 'release/0.0.10'
2 parents 775f1a0 + a4dae90 commit fc48d18

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
0.0.10
5+
-----
6+
allow to provide annotation max length to use
7+
48
0.0.9
59
-----
610
Fix issue : within a class, the additonal multi lines are not indented correcly

Element/PhpAnnotation.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ class PhpAnnotation extends AbstractElement
1616
* @var string
1717
*/
1818
protected $content;
19+
/**
20+
* @var int
21+
*/
22+
protected $maxLength;
1923
/**
2024
* @param string $name
2125
* @param string $content
26+
* @param int $maxLength
2227
*/
23-
public function __construct($name, $content)
28+
public function __construct($name, $content, $maxLength = self::MAX_LENGTH)
2429
{
2530
parent::__construct($name);
26-
$this->setContent($content);
31+
$this
32+
->setContent($content)
33+
->setMaxLength($maxLength);
2734
}
2835
/**
2936
* @param string $content
@@ -57,8 +64,8 @@ protected function getPhpContent()
5764
$content = array(
5865
$fullContent,
5966
);
60-
if (strlen($fullContent) > static::MAX_LENGTH) {
61-
$content = str_split($fullContent, static::MAX_LENGTH);
67+
if (strlen($fullContent) > $this->getMaxLength()) {
68+
$content = str_split($fullContent, $this->getMaxLength());
6269
}
6370
return array_map(function ($element) {
6471
return sprintf(' %s', $element);
@@ -88,4 +95,20 @@ public function getChildrenTypes()
8895
{
8996
return array();
9097
}
98+
/**
99+
* @param int $maxlength
100+
* @return PhpAnnotation
101+
*/
102+
public function setMaxLength($maxlength)
103+
{
104+
$this->maxLength = $maxlength;
105+
return $this;
106+
}
107+
/**
108+
* @return int
109+
*/
110+
public function getMaxLength()
111+
{
112+
return $this->maxLength;
113+
}
91114
}

Tests/Element/PhpAnnotationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public function testGetSeveralLinesWithNamePhpDeclaration()
4141
" * This sample annotation is on one line", $annotation->getPhpDeclaration());
4242
}
4343

44+
public function testGetSeveralLinesLargerWithNamePhpDeclaration()
45+
{
46+
$annotation = new PhpAnnotation('description', str_repeat('This sample annotation is on one line ', 7), 300);
47+
48+
$this->assertSame(" * @description This sample annotation is on one line This sample annotation is on one line This sample annotation is on one line This sample annotation is on one line This sample annotation is on one line This sample annotation is on one line This sample annotation is on one line", $annotation->getPhpDeclaration());
49+
}
50+
4451
/**
4552
* @expectedException InvalidArgumentException
4653
*/

0 commit comments

Comments
 (0)