File tree 5 files changed +9
-31
lines changed
5 files changed +9
-31
lines changed Original file line number Diff line number Diff line change 4
4
5
5
class JuniorDeveloper
6
6
{
7
- public function writeBadCode ()
7
+ public function writeBadCode (): string
8
8
{
9
9
return 'Some junior developer generated code... ' ;
10
10
}
Original file line number Diff line number Diff line change 23
23
24
24
You can also find these code on `GitHub `_
25
25
26
- Usage.php
27
-
28
- .. literalinclude :: Usage.php
29
- :language: php
30
- :linenos:
31
-
32
26
TeamLead.php
33
27
34
28
.. literalinclude :: TeamLead.php
Original file line number Diff line number Diff line change 4
4
5
5
class TeamLead
6
6
{
7
- /** @var JuniorDeveloper */
8
- protected $ slave ;
7
+ /**
8
+ * @var JuniorDeveloper
9
+ */
10
+ private $ junior ;
9
11
10
12
/**
11
- * Give junior developer into teamlead submission.
12
- *
13
13
* @param JuniorDeveloper $junior
14
14
*/
15
15
public function __construct (JuniorDeveloper $ junior )
16
16
{
17
- $ this ->slave = $ junior ;
17
+ $ this ->junior = $ junior ;
18
18
}
19
19
20
- /**
21
- * TeamLead drink coffee, junior work.
22
- *
23
- * @return mixed
24
- */
25
- public function writeCode ()
20
+ public function writeCode (): string
26
21
{
27
- return $ this ->slave ->writeBadCode ();
22
+ return $ this ->junior ->writeBadCode ();
28
23
}
29
24
}
Original file line number Diff line number Diff line change 4
4
5
5
use DesignPatterns \More \Delegation ;
6
6
7
- /**
8
- * DelegationTest tests the delegation pattern.
9
- */
10
7
class DelegationTest extends \PHPUnit_Framework_TestCase
11
8
{
12
9
public function testHowTeamLeadWriteCode ()
13
10
{
14
11
$ junior = new Delegation \JuniorDeveloper ();
15
12
$ teamLead = new Delegation \TeamLead ($ junior );
13
+
16
14
$ this ->assertEquals ($ junior ->writeBadCode (), $ teamLead ->writeCode ());
17
15
}
18
16
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments