Skip to content

Commit 73776dc

Browse files
author
Andrew Mischenko
committed
Add modifier traits
1 parent 8b71a4e commit 73776dc

File tree

10 files changed

+122
-147
lines changed

10 files changed

+122
-147
lines changed

src/Model/ClassModel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
use Krlove\Generator\Model\Traits\DocBlockTrait;
66
use Krlove\Generator\RenderableModel;
77

8+
/**
9+
* Class ClassModel
10+
* @package Krlove\Generator\Model
11+
*/
812
class ClassModel extends RenderableModel
913
{
1014
use DocBlockTrait;

src/Model/ClassNameModel.php

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Krlove\Generator\Model;
44

55
use Krlove\Generator\Exception\ValidationException;
6+
use Krlove\Generator\Model\Traits\AbstractModifierTrait;
7+
use Krlove\Generator\Model\Traits\FinalModifierTrait;
68
use Krlove\Generator\RenderableModel;
79

810
/**
@@ -11,21 +13,14 @@
1113
*/
1214
class ClassNameModel extends RenderableModel
1315
{
16+
use AbstractModifierTrait;
17+
use FinalModifierTrait;
18+
1419
/**
1520
* @var string
1621
*/
1722
protected $name;
1823

19-
/**
20-
* @var boolean
21-
*/
22-
protected $final;
23-
24-
/**
25-
* @var boolean
26-
*/
27-
protected $abstract;
28-
2924
/**
3025
* @var string
3126
*/
@@ -147,42 +142,4 @@ public function addImplements($implements)
147142

148143
return $this;
149144
}
150-
151-
/**
152-
* @return boolean
153-
*/
154-
public function isFinal()
155-
{
156-
return $this->final;
157-
}
158-
159-
/**
160-
* @param boolean $final
161-
* @return $this
162-
*/
163-
public function setFinal($final = true)
164-
{
165-
$this->final = boolval($final);
166-
167-
return $this;
168-
}
169-
170-
/**
171-
* @return boolean
172-
*/
173-
public function isAbstract()
174-
{
175-
return $this->abstract;
176-
}
177-
178-
/**
179-
* @param boolean $abstract
180-
* @return $this
181-
*/
182-
public function setAbstract($abstract = true)
183-
{
184-
$this->abstract = boolval($abstract);
185-
186-
return $this;
187-
}
188145
}

src/Model/MethodModel.php

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
namespace Krlove\Generator\Model;
44

55
use Krlove\Generator\Exception\ValidationException;
6+
use Krlove\Generator\Model\Traits\AbstractModifierTrait;
67
use Krlove\Generator\Model\Traits\AccessModifierTrait;
78
use Krlove\Generator\Model\Traits\DocBlockTrait;
9+
use Krlove\Generator\Model\Traits\FinalModifierTrait;
10+
use Krlove\Generator\Model\Traits\StaticModifierTrait;
811
use Krlove\Generator\RenderableModel;
912

1013
/**
@@ -14,29 +17,17 @@
1417
*/
1518
class MethodModel extends RenderableModel
1619
{
20+
use AbstractModifierTrait;
1721
use AccessModifierTrait;
1822
use DocBlockTrait;
23+
use FinalModifierTrait;
24+
use StaticModifierTrait;
1925

2026
/**
2127
* @var string
2228
*/
2329
protected $name;
2430

25-
/**
26-
* @var boolean
27-
*/
28-
protected $static;
29-
30-
/**
31-
* @var boolean
32-
*/
33-
protected $final;
34-
35-
/**
36-
* @var boolean;
37-
*/
38-
protected $abstract;
39-
4031
/**
4132
* @var ArgumentModel[]
4233
*/
@@ -159,63 +150,6 @@ public function addArgument(ArgumentModel $argument)
159150
return $this;
160151
}
161152

162-
/**
163-
* @return boolean
164-
*/
165-
public function isStatic()
166-
{
167-
return $this->static;
168-
}
169-
170-
/**
171-
* @param boolean $static
172-
* @return $this
173-
*/
174-
public function setStatic($static = true)
175-
{
176-
$this->static = boolval($static);
177-
178-
return $this;
179-
}
180-
181-
/**
182-
* @return boolean
183-
*/
184-
public function isFinal()
185-
{
186-
return $this->final;
187-
}
188-
189-
/**
190-
* @param boolean $final
191-
* @return $this
192-
*/
193-
public function setFinal($final = true)
194-
{
195-
$this->final = boolval($final);
196-
197-
return $this;
198-
}
199-
200-
/**
201-
* @return boolean
202-
*/
203-
public function isAbstract()
204-
{
205-
return $this->abstract;
206-
}
207-
208-
/**
209-
* @param boolean $abstract
210-
* @return $this
211-
*/
212-
public function setAbstract($abstract = true)
213-
{
214-
$this->abstract = boolval($abstract);
215-
216-
return $this;
217-
}
218-
219153
/**
220154
* @return string
221155
*/

src/Model/PropertyModel.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Krlove\Generator\Model\Traits\AccessModifierTrait;
66
use Krlove\Generator\Model\Traits\DocBlockTrait;
7+
use Krlove\Generator\Model\Traits\StaticModifierTrait;
78
use Krlove\Generator\Model\Traits\ValueTrait;
89
use Krlove\Generator\RenderableModel;
910

@@ -16,18 +17,14 @@ class PropertyModel extends RenderableModel
1617
{
1718
use AccessModifierTrait;
1819
use DocBlockTrait;
20+
use StaticModifierTrait;
1921
use ValueTrait;
2022

2123
/**
2224
* @var string
2325
*/
2426
protected $name;
2527

26-
/**
27-
* @var boolean
28-
*/
29-
protected $static;
30-
3128
/**
3229
* PropertyModel constructor.
3330
* @param string $name
@@ -88,23 +85,4 @@ public function setName($name)
8885

8986
return $this;
9087
}
91-
92-
/**
93-
* @return boolean
94-
*/
95-
public function isStatic()
96-
{
97-
return $this->static;
98-
}
99-
100-
/**
101-
* @param boolean $static
102-
* @return $this
103-
*/
104-
public function setStatic($static)
105-
{
106-
$this->static = boolval($static);
107-
108-
return $this;
109-
}
11088
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Krlove\Generator\Model\Traits;
4+
5+
/**
6+
* Trait AbstractModifierTrait
7+
* @package Krlove\Generator\Model\Traits
8+
*/
9+
trait AbstractModifierTrait
10+
{
11+
/**
12+
* @var boolean;
13+
*/
14+
protected $abstract;
15+
16+
/**
17+
* @return boolean
18+
*/
19+
public function isAbstract()
20+
{
21+
return $this->abstract;
22+
}
23+
24+
/**
25+
* @param boolean $abstract
26+
* @return $this
27+
*/
28+
public function setAbstract($abstract = true)
29+
{
30+
$this->abstract = boolval($abstract);
31+
32+
return $this;
33+
}
34+
}

src/Model/Traits/AccessModifierTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Krlove\Generator\Model\Traits;
44

55
/**
6-
* Class AccessModifierTrait
6+
* Trait AccessModifierTrait
77
* @package Krlove\Generator\Model\Traits
88
*/
99
trait AccessModifierTrait

src/Model/Traits/DocBlockTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Krlove\Generator\Model\DocBlockModel;
66

77
/**
8-
* Class DocBlockTrait
8+
* Trait DocBlockTrait
99
* @package Krlove\Generator\Model\Traits
1010
*/
1111
trait DocBlockTrait
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Krlove\Generator\Model\Traits;
4+
5+
/**
6+
* Trait FinalModifierTrait
7+
* @package Krlove\Generator\Model\Traits
8+
*/
9+
trait FinalModifierTrait
10+
{
11+
/**
12+
* @var boolean
13+
*/
14+
protected $final;
15+
16+
/**
17+
* @return boolean
18+
*/
19+
public function isFinal()
20+
{
21+
return $this->final;
22+
}
23+
24+
/**
25+
* @param boolean $final
26+
* @return $this
27+
*/
28+
public function setFinal($final = true)
29+
{
30+
$this->final = boolval($final);
31+
32+
return $this;
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Krlove\Generator\Model\Traits;
4+
5+
/**
6+
* Trait StaticMidifierTrait
7+
* @package Krlove\Generator\Model\Traits
8+
*/
9+
trait StaticModifierTrait
10+
{
11+
/**
12+
* @var boolean
13+
*/
14+
protected $static;
15+
16+
/**
17+
* @return boolean
18+
*/
19+
public function isStatic()
20+
{
21+
return $this->static;
22+
}
23+
24+
/**
25+
* @param boolean $static
26+
* @return $this
27+
*/
28+
public function setStatic($static = true)
29+
{
30+
$this->static = boolval($static);
31+
32+
return $this;
33+
}
34+
}

src/Model/Traits/ValueTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Krlove\Generator\Model\Traits;
44

55
/**
6-
* Class PHPValueTrait
6+
* Trait PHPValueTrait
77
* @package Krlove\Generator\Model\Traits
88
*/
99
trait ValueTrait

0 commit comments

Comments
 (0)