diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-05-21 09:42:38 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-05-21 09:42:38 +0200 |
commit | ae52a447e990cde99d76cfa584040b2e10e7ffac (patch) | |
tree | 79f619bdbc6aad46dc836abeb15037cf33766b06 | |
parent | 029571e80d5fff1f9476e5210ca4bd1b3f2b2229 (diff) | |
download | View-ae52a447e990cde99d76cfa584040b2e10e7ffac.zip View-ae52a447e990cde99d76cfa584040b2e10e7ffac.tar.gz View-ae52a447e990cde99d76cfa584040b2e10e7ffac.tar.bz2 |
Move to PSR-1 and PSR-2.
-rw-r--r-- | Documentation/En/Index.xyl | 40 | ||||
-rw-r--r-- | Documentation/Fr/Index.xyl | 39 | ||||
-rw-r--r-- | Test/Unit/Viewable.php | 14 | ||||
-rw-r--r-- | Viewable.php | 18 |
4 files changed, 56 insertions, 55 deletions
diff --git a/Documentation/En/Index.xyl b/Documentation/En/Index.xyl index f624dc6..18b2ac6 100644 --- a/Documentation/En/Index.xyl +++ b/Documentation/En/Index.xyl @@ -83,20 +83,22 @@ for more simplicity.</li> </ul> <p>Let's start by writing the <code>SuperView</code> class:</p> - <pre data-line="44"><code class="language-php">class SuperView implements Hoa\View\Viewable { - + <pre data-line="46"><code class="language-php">class SuperView implements Hoa\View\Viewable +{ protected $_in = null; protected $_out = null; protected $_data = null; protected $_router = null; - public function __construct ( $in, - Hoa\Stream\IStream\Out $out, - Hoa\Router\Router $router = null, - StdClass $data = null ) { - - if(null === $data) + public function __construct( + $in, + Hoa\Stream\IStream\Out $out, + Hoa\Router\Router $router = null, + StdClass $data = null + ) { + if (null === $data) { $data = new StdClass(); + } $this->_in = $in; $this->_out = $out; @@ -106,18 +108,18 @@ return; } - public function getOutputStream ( ) { - + public function getOutputStream() + { return $this->_out; } - public function getData ( ) { - + public function getData() + { return $this->_data; } - public function render ( ) { - + public function render() + { $data = $this->getData(); $router = $this->getRouter(); @@ -131,8 +133,8 @@ return; } - public function getRouter ( ) { - + public function getRouter() + { return $this->_router; } }</code></pre> @@ -144,7 +146,7 @@ variables (in addition to <code class="language-php">$this</code>), namely <code class="language-php">$data</code> and <code class="language-php">$router</code>, to ease the usage. Finally the - line 44 uses the output stream to write computed data.</p> + line 46 uses the output stream to write computed data.</p> <p>Now, let's test by writing a <code>Test.php</code> file:</p> <pre data-line="9,17"><code class="language-php">// Output. $output = new Hoa\Http\Response(); @@ -171,8 +173,8 @@ $superview->render();</code></pre> &lt;h1>foobar&lt;/h1></code></pre> <p>Excellent. Now, we will add the <code>import</code> method to create <strong>sub-views</strong>. Thus in the <code>SuperView</code> class:</p> - <pre><code class="language-php"> public function import ( $in, $data = null ) { - + <pre><code class="language-php"> public function import($in, $data = null) + { $new = new static( $in, $this->getOutputStream(), diff --git a/Documentation/Fr/Index.xyl b/Documentation/Fr/Index.xyl index 127d7fa..4a52c8a 100644 --- a/Documentation/Fr/Index.xyl +++ b/Documentation/Fr/Index.xyl @@ -87,20 +87,22 @@ <code>StdClass</code></a> pour plus de simplicité.</li> </ul> <p>Commençons par écrire la classe <code>SuperView</code> :</p> - <pre data-line="44"><code class="language-php">class SuperView implements Hoa\View\Viewable { - + <pre data-line="46"><code class="language-php">class SuperView implements Hoa\View\Viewable +{ protected $_in = null; protected $_out = null; protected $_data = null; protected $_router = null; - public function __construct ( $in, - Hoa\Stream\IStream\Out $out, - Hoa\Router\Router $router = null, - StdClass $data = null ) { - - if(null === $data) + public function __construct( + $in, + Hoa\Stream\IStream\Out $out, + Hoa\Router\Router $router = null, + StdClass $data = null + ) { + if (null === $data) { $data = new StdClass(); + } $this->_in = $in; $this->_out = $out; @@ -110,18 +112,18 @@ return; } - public function getOutputStream ( ) { - + public function getOutputStream() + { return $this->_out; } - public function getData ( ) { - + public function getData() + { return $this->_data; } - public function render ( ) { - + public function render() + { $data = $this->getData(); $router = $this->getRouter(); @@ -135,8 +137,8 @@ return; } - public function getRouter ( ) { - + public function getRouter() + { return $this->_router; } }</code></pre> @@ -149,7 +151,7 @@ <code class="language-php">$this</code>), à savoir <code class="language-php">$data</code> et <code class="language-php">$router</code>, pour lui faciliter l'écriture. - Enfin, la ligne 44 utilise le flux de sortie pour écrire les données.</p> + Enfin, la ligne 46 utilise le flux de sortie pour écrire les données.</p> <p>Testons en écrivant un fichier <code>Test.php</code> :</p> <pre data-line="9,17"><code class="language-php">// Output. $output = new Hoa\Http\Response(); @@ -177,7 +179,8 @@ $superview->render();</code></pre> <p>Excellent. Maintenant ajoutons le moyen de créer des <strong>sous-vues</strong> avec la méthode <code>import</code> par exemple. Ainsi, nous ajoutons dans la classe <code>SuperView</code> :</p> - <pre><code class="language-php"> public function import ( $in, $data = null ) { + <pre><code class="language-php"> public function import($in, $data = null) + { $new = new static( $in, diff --git a/Test/Unit/Viewable.php b/Test/Unit/Viewable.php index 200bec6..1ee42f0 100644 --- a/Test/Unit/Viewable.php +++ b/Test/Unit/Viewable.php @@ -8,7 +8,7 @@ * * New BSD License * - * Copyright © 2007-2015, Ivan Enderlin. All rights reserved. + * Copyright © 2007-2015, Hoa community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -43,15 +43,13 @@ use Hoa\Test; * * Test suite of the interface. * - * @author Ivan Enderlin <ivan.enderlin@hoa-project.net> - * @copyright Copyright © 2007-2015 Ivan Enderlin. + * @copyright Copyright © 2007-2015 Hoa community * @license New BSD License */ - -class Viewable extends Test\Unit\Suite { - - public function case_interface ( ) { - +class Viewable extends Test\Unit\Suite +{ + public function case_interface() + { $this ->when($result = new \Mock\Hoa\View\Viewable()) ->object($result) diff --git a/Viewable.php b/Viewable.php index 512d8be..6cb9b5f 100644 --- a/Viewable.php +++ b/Viewable.php @@ -8,7 +8,7 @@ * * New BSD License * - * Copyright © 2007-2015, Ivan Enderlin. All rights reserved. + * Copyright © 2007-2015, Hoa community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -41,34 +41,32 @@ namespace Hoa\View; * * Describe what a view could be. * - * @author Ivan Enderlin <ivan.enderlin@hoa-project.net> - * @copyright Copyright © 2007-2015 Ivan Enderlin. + * @copyright Copyright © 2007-2015 Hoa community * @license New BSD License */ - -interface Viewable { - +interface Viewable +{ /** * @description 'Get the output stream.'; * @ensures \result: \Hoa\Stream\IStream\Out; */ - public function getOutputStream ( ); + public function getOutputStream(); /** * @description 'Get the data holded by the view.'; * @ensures \result: \Hoa\Core\Data; */ - public function getData ( ); + public function getData(); /** * @description 'Make a render of the view.'; * @ensures \result: void; */ - public function render ( ); + public function render(); /** * @description 'Get router.'; * @ensures \result: \Hoa\Router; */ - public function getRouter ( ); + public function getRouter(); } |