dox Executable Documentation

Dynamic values

Method call

Given the class 'class IntegerModel { public $value; public function __construct($int) { $this->value = $int; } public function isBig() { return $this->value > 3; } public function isNotBig() { return !$this->isBig(); } }'
Given the class 'class MethodModel { public $number; public function __construct($number) { $this->number = new IntegerModel($number); } }'
Given the model is instance of class 'MethodModel' 2
When I render ' <div property="number"> <span property="value">X</span> is a <span property="isBig">BIG</span><span property="isNotBig">small</span> number </div> '
Then the result should be ' <div property="number"> <span property="value">2</span> is a <span property="isNotBig">small</span> number </div> '

Value from closure

Given the class 'class StringModel { public function __construct() { $this->shorten = function ($element) { return substr($element->getChildren()->first()->getText(), 0, 7); }; } }'
Given the model is instance of class 'StringModel'
When I render '<div property="shorten">Shorten this</div>'
Then the result should be '<div property="shorten">Shorten</div>'

Value from closure in array

Given the model object array('test' => function (Element $element) { $element->setAttribute('class', 'this'); return 'Test'; })
When I render '<div property="test">Replace this</div>'
Then the result should be '<div property="test" class="this">Test</div>'

Do not mistake function names for callable

Given the model object array('notCallable' => 'date')
When I render '<div property="notCallable"></div>'
Then the result should be '<div property="notCallable">date</div>'
Given the class 'class SomeModel { public function __construct() { $this->neither = "date"; } }'
Given the model is instance of class 'SomeModel'
When I render '<div property="neither"></div>'
Then the result should be '<div property="neither">date</div>'

Pass arguments

Given the model object array('say' => function (Element $element) { return $element->getAttribute('data-what')->getValue(); })
When I render '<div property="say" data-what="Hello World">Say it</div>'
Then the result should be '<div property="say" data-what="Hello World">Hello World</div>'

Favor methods

Given the class 'class PrivateAttribute { private $value; public function __construct($int) { $this->value = $int; } public function value() { return $this->value . "!"; } }'
Given the model is instance of class 'PrivateAttribute' 'foo'
When I render '<div property="value"></div>'
Then the result should be '<div property="value">foo!</div>'