mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 18:50:11 +02:00
Merge pull request #309 from k-gun/master
The "protected" keyword should be used in order to subclasses to use …
This commit is contained in:
@@ -7,7 +7,7 @@ abstract class Text
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $text;
|
protected $text;
|
||||||
|
|
||||||
public function __construct(string $text)
|
public function __construct(string $text)
|
||||||
{
|
{
|
||||||
|
@@ -7,7 +7,7 @@ Purpose
|
|||||||
SimpleFactory is a simple factory pattern.
|
SimpleFactory is a simple factory pattern.
|
||||||
|
|
||||||
It differs from the static factory because it is not static.
|
It differs from the static factory because it is not static.
|
||||||
Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock it.
|
Therefore, you can have multiple factories, differently parameterized, you can subclass it and you can mock it.
|
||||||
It always should be preferred over a static factory!
|
It always should be preferred over a static factory!
|
||||||
|
|
||||||
UML Diagram
|
UML Diagram
|
||||||
|
@@ -10,7 +10,7 @@ testable, maintainable and extendable code.
|
|||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
DatabaseConfiguration gets injected and ``DatabaseConnection`` will get all that it
|
``DatabaseConfiguration`` gets injected and ``DatabaseConnection`` will get all that it
|
||||||
needs from ``$config``. Without DI, the configuration would be created
|
needs from ``$config``. Without DI, the configuration would be created
|
||||||
directly in ``DatabaseConnection``, which is not very good for testing and
|
directly in ``DatabaseConnection``, which is not very good for testing and
|
||||||
extending it.
|
extending it.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: DesignPatternsPHP 1.0\n"
|
"Project-Id-Version: DesignPatternsPHP 1.0\n"
|
||||||
@@ -31,7 +31,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: ../../Creational/SimpleFactory/README.rst:12
|
#: ../../Creational/SimpleFactory/README.rst:12
|
||||||
msgid ""
|
msgid ""
|
||||||
"Therefore, you can have multiple factories, differently parametrized, you "
|
"Therefore, you can have multiple factories, differently parameterized, you "
|
||||||
"can subclass it and you can mock-up it."
|
"can subclass it and you can mock-up it."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ msgstr ""
|
|||||||
#: ../../Creational/SimpleFactory/README.rst:9
|
#: ../../Creational/SimpleFactory/README.rst:9
|
||||||
msgid ""
|
msgid ""
|
||||||
"It differs from the static factory because it is not static. "
|
"It differs from the static factory because it is not static. "
|
||||||
"Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock it."
|
"Therefore, you can have multiple factories, differently parameterized, you can subclass it and you can mock it."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../../Creational/SimpleFactory/README.rst:11
|
#: ../../Creational/SimpleFactory/README.rst:11
|
||||||
@@ -52,4 +52,4 @@ msgstr ""
|
|||||||
|
|
||||||
#: ../../Creational/SimpleFactory/README.rst:52
|
#: ../../Creational/SimpleFactory/README.rst:52
|
||||||
msgid "Test"
|
msgid "Test"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@@ -28,7 +28,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: ../../Structural/DependencyInjection/README.rst:13
|
#: ../../Structural/DependencyInjection/README.rst:13
|
||||||
msgid ""
|
msgid ""
|
||||||
"DatabaseConfiguration gets injected and ``DatabaseConnection`` will get all that it "
|
"``DatabaseConfiguration`` gets injected and ``DatabaseConnection`` will get all that it "
|
||||||
"needs from ``$config``. Without DI, the configuration would be created "
|
"needs from ``$config``. Without DI, the configuration would be created "
|
||||||
"directly in ``DatabaseConnection``, which is not very good for testing and "
|
"directly in ``DatabaseConnection``, which is not very good for testing and "
|
||||||
"extending it."
|
"extending it."
|
||||||
@@ -71,4 +71,4 @@ msgstr ""
|
|||||||
|
|
||||||
#: ../../Structural/DependencyInjection/README.rst:53
|
#: ../../Structural/DependencyInjection/README.rst:53
|
||||||
msgid "Test"
|
msgid "Test"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
Reference in New Issue
Block a user