<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
					xmlns:content="http://purl.org/rss/1.0/modules/content/"
					xmlns:wfw="http://wellformedweb.org/CommentAPI/"
					xmlns:atom="http://www.w3.org/2005/Atom"
				  >
<channel>
<atom:link rel="self"  type="application/rss+xml"  href="http://rulinux.net/rss_from_sect_4_subsect_10_thread_37629"  />
<title>rulinux.net - Форум - Talks - [php][patterns][KISS]Hello, World!</title>
<link>http://rulinux.net/</link>
<description><![CDATA[Портал о GNU/Linux и не только]]></description>
<image><title>rulinux.net - Форум - Talks - [php][patterns][KISS]Hello, World!</title>
<link>http://rulinux.net/</link>
<url>http://rulinux.net/rss_icon.png</url>
</image>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147342</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147342</guid>
<pubDate>Thu, 12 Jul 2012 11:11:58 +0400</pubDate>
<description><![CDATA[<p>Что _ты_ создаёшь чтобы она проинициализировалась? Всегда есть какой-то общий механизм инициализации, это не твой кастомный функционал ака контроллер.</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147340</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147340</guid>
<pubDate>Thu, 12 Jul 2012 11:06:49 +0400</pubDate>
<description><![CDATA[<p>А что у тебя это формочку инициализирует? Или она таки создается сама-собой?</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147335</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147335</guid>
<pubDate>Thu, 12 Jul 2012 10:59:43 +0400</pubDate>
<description><![CDATA[<p>Вот тебе и ЛОЛ. Ты формочки в этом своём двараза-ку-девелопыре как лепишь? Сначала делаешь формочку, потом функционал к ней прописываешь, небось. И Создаётся всё в том же порядке из главного окна, да? Или у тебя при запуске программы сначала в терминале стартует некий контроллер, который обрабатывает ввод от пользователя и и отображает его в подходящей формочке? А почему в веб-десигне должно быть всё через жопу?</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147332</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147332</guid>
<pubDate>Thu, 12 Jul 2012 10:52:44 +0400</pubDate>
<description><![CDATA[<p>лол.</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147330</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147330</guid>
<pubDate>Thu, 12 Jul 2012 10:51:41 +0400</pubDate>
<description><![CDATA[<p>Как &quot;как&quot;? По определению, вот как. </p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147328</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147328</guid>
<pubDate>Thu, 12 Jul 2012 10:47:52 +0400</pubDate>
<description><![CDATA[<p>интерфейс от интерфейса? это как?</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147326</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147326</guid>
<pubDate>Thu, 12 Jul 2012 10:46:23 +0400</pubDate>
<description><![CDATA[<p>Само по себе это ничем не хуже контроллера, создающего вью. Может быть даже лучше - всё-таки гуй пляшет от интерфейса. </p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147323</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147323</guid>
<pubDate>Thu, 12 Jul 2012 10:34:32 +0400</pubDate>
<description><![CDATA[<p>Так в чем и прикол. Апофеоз программистской мысли. </p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147320</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147320</guid>
<pubDate>Thu, 12 Jul 2012 10:30:32 +0400</pubDate>
<description><![CDATA[<p>Ну и нахрен тут фабрика, facade и декораторы, strategy и прочий хлам? Быдлокод какой-то, воняющий энтерпрайзом. <br><br>А ещё view создаёт контроллер, что есть бред.</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147306</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147306</guid>
<pubDate>Thu, 12 Jul 2012 09:32:05 +0400</pubDate>
<description><![CDATA[<p>Приведёшь деклассированную реализацию MVC для сравнения?</p>]]></description>
</item>
<item>
<title>Re:[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147303</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147303</guid>
<pubDate>Thu, 12 Jul 2012 08:30:52 +0400</pubDate>
<description><![CDATA[<p>Именно за такую херню я ненавижу обьектное, я за деклассированный код.</p>]]></description>
</item>
<item>
<title>[php][patterns][KISS]Hello, World!</title>
<link>https://rulinux.net/message.php?newsid=37629&amp;page=1#147298</link>
<guid>https://rulinux.net/message.php?newsid=37629&amp;page=1#147298</guid>
<pubDate>Thu, 12 Jul 2012 07:51:06 +0400</pubDate>
<description><![CDATA[<p>&#92;Ъ[<a href="http://www.phppatterns.com/docs/design/hello_world_in_patterns">http://www.phppatterns.com/docs/design/hello_world_in_patterns</a>]{</p><p></p><p><fieldset><legend>]</legend><code><br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/********************************************************************<br />
Model-View-Controller implementation according to POSA<br />
(Pattern-Oriented Software Architecture<br />
&nbsp; http://www.hillside.net/patterns/books/Siemens/book.html)<br />
********************************************************************/</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldController <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$model</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$model</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> handleEvent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStrategy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span>2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldModel <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$observers</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$strategy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> attach<span style="color: #009900;">&#40;</span><span style="color: #000088;">$observer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">observers</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$observer</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> getData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$facade</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldFacade<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$facade</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getHelloWorld</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> addText<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> setStrategy<span style="color: #009900;">&#40;</span><span style="color: #000088;">$strategy</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$strategy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> notify<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">observers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$observer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$observer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldView <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$model</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$model</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">makeController</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> makeController<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldController<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> display<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp;<br />
<span style="color: #666666; font-style: italic;">/*********************************************************************<br />
&quot;Business logic&quot;<br />
********************************************************************/</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorld <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;Hello world&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldDecorator <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$helloworld</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$helloworld</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helloworld</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$helloworld</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helloworld</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
abstract <span style="color: #000000; font-weight: bold;">class</span> HelloWorldEmphasisStrategy <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; abstract <span style="color: #000000; font-weight: bold;">function</span> emphasize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldBangEmphasisStrategy <span style="color: #000000; font-weight: bold;">extends</span> HelloWorldEmphasisStrategy <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> emphasize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;!&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldRepetitionEmphasisStrategy <span style="color: #000000; font-weight: bold;">extends</span> HelloWorldEmphasisStrategy <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> emphasize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; and &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; again&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldEmphasizer <span style="color: #000000; font-weight: bold;">extends</span> HelloWorldDecorator <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$strategy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> HelloWorldEmphasizer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$helloworld</span><span style="color: #339933;">,</span><span style="color: #000088;">$strategy</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$strategy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$helloworld</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">emphasize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldStrategyFactory <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; static <span style="color: #000000; font-weight: bold;">function</span> make<span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'repetition'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">makeRepetitionStrategy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">makeBangStrategy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; static <span style="color: #000000; font-weight: bold;">function</span> makeBangStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldBangEmphasisStrategy<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; static <span style="color: #000000; font-weight: bold;">function</span> makeRepetitionStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldRepetitionEmphasisStrategy<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldFormatter <span style="color: #000000; font-weight: bold;">extends</span> HelloWorldDecorator <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">function</span> execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">class</span> HelloWorldFacade <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$strategy</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$strategyType</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span> <span style="color: #339933;">=</span> HelloWorldStrategyFactory<span style="color: #339933;">::</span><span style="color: #004000;">make</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strategyType</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> getHelloWorld<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$formatter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldFormatter<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> HelloWorldEmphasizer<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> HelloWorld<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">strategy</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$formatter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldModel<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HelloWorldView<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$controller</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$controller</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">handleEvent</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'argv'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp;</code></fieldset></p><p>}</p><p>Охбле.</p>]]></description>
</item>
</channel>
</rss>