Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/FactoryMethod/Sample/Implemention/SUV.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:05
* Time: 16:05.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Implemention;


use Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces\ProductInterface;

class SUV implements ProductInterface
{

public function action()
{
// TODO: Implement action() method.
return "SUV";
return 'SUV';
}
}
}
6 changes: 2 additions & 4 deletions src/FactoryMethod/Sample/Implemention/SUVFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:04
* Time: 16:04.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Implemention;


use Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces\FactoryInterface;

class SUVFactory implements FactoryInterface
{

public static function create()
{
// TODO: Implement create() method.
return new SUV();
}
}
}
8 changes: 3 additions & 5 deletions src/FactoryMethod/Sample/Implemention/Taxi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:06
* Time: 16:06.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Implemention;


use Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces\ProductInterface;

class Taxi implements ProductInterface
{

public function action()
{
// TODO: Implement action() method.
return "Taxi";
return 'Taxi';
}
}
}
6 changes: 2 additions & 4 deletions src/FactoryMethod/Sample/Implemention/TaxiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:07
* Time: 16:07.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Implemention;


use Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces\FactoryInterface;

class TaxiFactory implements FactoryInterface
{

public static function create()
{
// TODO: Implement create() method.
return new Taxi();
}
}
}
5 changes: 2 additions & 3 deletions src/FactoryMethod/Sample/Interfaces/FactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:02
* Time: 16:02.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces;


interface FactoryInterface
{
public static function create();
}
}
5 changes: 2 additions & 3 deletions src/FactoryMethod/Sample/Interfaces/ProductInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:03
* Time: 16:03.
*/

namespace Sockstack\DesignPattern\FactoryMethod\Sample\Interfaces;


interface ProductInterface
{
public function action();
}
}
5 changes: 2 additions & 3 deletions tests/FactoryMethodText.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Created by PhpStorm.
* User: Administrator
* Date: 2018/11/8
* Time: 16:09
* Time: 16:09.
*/

namespace Sockstack\DesignPattern\Test;


use PHPUnit\Framework\TestCase;
use Sockstack\DesignPattern\FactoryMethod\Sample\Implemention\SUV;
use Sockstack\DesignPattern\FactoryMethod\Sample\Implemention\SUVFactory;
Expand All @@ -25,4 +24,4 @@ public function testFactoryMethod()
$taxi = TaxiFactory::create();
$this->assertTrue($taxi instanceof Taxi);
}
}
}