To PSR-x format

This commit is contained in:
bzick
2013-07-29 14:58:14 +04:00
parent 4edd0e1708
commit 3674de41cb
27 changed files with 2071 additions and 1674 deletions

View File

@@ -14,7 +14,8 @@ use Fenom;
* Primitive template
* @author Ivan Shalganov <a.cobest@gmail.com>
*/
class Render extends \ArrayObject {
class Render extends \ArrayObject
{
private static $_props = array(
"name" => "runtime",
"base_name" => "",
@@ -72,7 +73,8 @@ class Render extends \ArrayObject {
* @param callable $code template body
* @param array $props
*/
public function __construct(Fenom $fenom, \Closure $code, array $props = array()) {
public function __construct(Fenom $fenom, \Closure $code, array $props = array())
{
$this->_fenom = $fenom;
$props += self::$_props;
$this->_name = $props["name"];
@@ -86,7 +88,8 @@ class Render extends \ArrayObject {
* Get template storage
* @return \Fenom
*/
public function getStorage() {
public function getStorage()
{
return $this->_fenom;
}
@@ -94,7 +97,8 @@ class Render extends \ArrayObject {
* Get depends list
* @return array
*/
public function getDepends() {
public function getDepends()
{
return $this->_depends;
}
@@ -102,7 +106,8 @@ class Render extends \ArrayObject {
* Get schema name
* @return string
*/
public function getScm() {
public function getScm()
{
return $this->_scm;
}
@@ -110,7 +115,8 @@ class Render extends \ArrayObject {
* Get provider of template source
* @return ProviderInterface
*/
public function getProvider() {
public function getProvider()
{
return $this->_fenom->getProvider($this->_scm);
}
@@ -118,7 +124,8 @@ class Render extends \ArrayObject {
* Get name without schema
* @return string
*/
public function getBaseName() {
public function getBaseName()
{
return $this->_base_name;
}
@@ -126,14 +133,16 @@ class Render extends \ArrayObject {
* Get parse options
* @return int
*/
public function getOptions() {
public function getOptions()
{
return $this->_options;
}
/**
* @return string
*/
public function __toString() {
public function __toString()
{
return $this->_name;
}
@@ -141,11 +150,13 @@ class Render extends \ArrayObject {
* Get template name
* @return string
*/
public function getName() {
public function getName()
{
return $this->_name;
}
public function getTime() {
public function getTime()
{
return $this->_time;
}
@@ -154,16 +165,17 @@ class Render extends \ArrayObject {
* Validate template
* @return bool
*/
public function isValid() {
if(count($this->_depends) === 1) { // if no external dependencies, only self
public function isValid()
{
if (count($this->_depends) === 1) { // if no external dependencies, only self
$provider = $this->_fenom->getProvider($this->_scm);
if($provider->getLastModified($this->_name) !== $this->_time) {
if ($provider->getLastModified($this->_name) !== $this->_time) {
return false;
}
} else {
foreach($this->_depends as $scm => $templates) {
foreach ($this->_depends as $scm => $templates) {
$provider = $this->_fenom->getProvider($scm);
if(!$provider->verify($templates)) {
if (!$provider->verify($templates)) {
return false;
}
}
@@ -176,7 +188,8 @@ class Render extends \ArrayObject {
* @param array $values for template
* @return Render
*/
public function display(array $values) {
public function display(array $values)
{
$this->exchangeArray($values);
$this->_code->__invoke($this);
return $this->exchangeArray(array());
@@ -188,7 +201,8 @@ class Render extends \ArrayObject {
* @return string
* @throws \Exception
*/
public function fetch(array $values) {
public function fetch(array $values)
{
ob_start();
try {
$this->display($values);
@@ -205,7 +219,8 @@ class Render extends \ArrayObject {
* @param $args
* @throws \BadMethodCallException
*/
public function __call($method, $args) {
throw new \BadMethodCallException("Unknown method ".$method);
public function __call($method, $args)
{
throw new \BadMethodCallException("Unknown method " . $method);
}
}