/iaLib/ia_examples/ia/Date/YearMonth_example.php
<?php
$ia_example = [
'title' => 'ia\Date\YearMonth', // fully qualified className
'summary' => '', // class summary
'full_example' => '', // full usage example, relative path from ia_examples, blank '' not shown.
'example_file' => 'code/ia/Date/YearMonth_example_code.php', // method by method example, blank '' not shown.
];
include( __DIR__ . '/../../template/ia_example_class.php');
/iaLib/ia_examples/code/ia/Date/YearMonth_example_code.php
use ia\Date\YearMonth;
use ia\DocumentIt\DocumentIt;
echo '<h3>Disclaimer: Auto generated file.
Please help us setting parameters to useful values and extending the examples.
</h3>';
try {
echo '<ul class="usage">';
///////// YearMonth::yearMonthDeduce(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_yearMonthDeduce'><b>YearMonth::yearMonthDeduce(<span class="type"></span> \$anyDate <span class="default">= 'now'</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\YearMonth", "yearMonthDeduce")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>YearMonth::yearMonthDeduce();
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
YearMonth::yearMonthDeduce()
);
echo "</pre>";
echo '</ol>';
///////// YearMonth::yearMonthGenerator('palabra', 'palabra'); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_yearMonthGenerator'><b>YearMonth::yearMonthGenerator(<span class="type">string</span> \$from, <span class="type">string</span> \$to) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\YearMonth", "yearMonthGenerator")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>YearMonth::yearMonthGenerator('palabra', 'palabra');
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
YearMonth::yearMonthGenerator('palabra', 'palabra')
);
echo "</pre>";
echo '</ol>';
///////// YearMonth::addYears('palabra'); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_addYears'><b>YearMonth::addYears(<span class="type">string</span> \$yearMonth, <span class="type">int</span> \$numberOfYears <span class="default">= 1</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\YearMonth", "addYears")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>YearMonth::addYears('palabra');
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
YearMonth::addYears('palabra')
);
echo "</pre>";
echo '</ol>';
///////// YearMonth::addMonths('palabra'); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_addMonths'><b>YearMonth::addMonths(<span class="type">string</span> \$yearMonth, <span class="type">int</span> \$numberOfMonths <span class="default">= 1</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\YearMonth", "addMonths")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>YearMonth::addMonths('palabra');
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
YearMonth::addMonths('palabra')
);
echo "</pre>";
echo '</ol>';
///////// YearMonth::valid('palabra'); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_valid'><b>YearMonth::valid(<span class="type">string</span> \$yearMonth, <span class="type"></span> \$min <span class="default">= null</span>, <span class="type"></span> \$max <span class="default">= null</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\YearMonth", "valid")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>YearMonth::valid('palabra');
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
YearMonth::valid('palabra')
);
echo "</pre>";
echo '</ol>';
/* PerfilExample adds new methods here */
echo '</ul>';
} catch(Exception $exception) { echo "<pre class='errorBlock'>$exception</pre>"; }
phpunit test file template
<?php
use ia\Date\YearMonth;
use PHPUnit\Framework\TestCase;
class YearMonthTest extends TestCase {
/**
* @dataProvider yearMonthDeduce_Provider
*
*/
public function test_yearMonthDeduce($anyDate , $expected) {
$this->assertEquals($expected, YearMonth::yearMonthDeduce($anyDate) );
}
function yearMonthDeduce_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider yearMonthGenerator_Provider
*
*/
public function test_yearMonthGenerator($from, $to , $expected) {
$this->assertEquals($expected, YearMonth::yearMonthGenerator($from, $to) );
}
function yearMonthGenerator_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider addYears_Provider
*
*/
public function test_addYears($yearMonth, $numberOfYears , $expected) {
$this->assertEquals($expected, YearMonth::addYears($yearMonth, $numberOfYears) );
}
function addYears_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider addMonths_Provider
*
*/
public function test_addMonths($yearMonth, $numberOfMonths , $expected) {
$this->assertEquals($expected, YearMonth::addMonths($yearMonth, $numberOfMonths) );
}
function addMonths_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider valid_Provider
*
*/
public function test_valid($yearMonth, $min, $max , $expected) {
$this->assertEquals($expected, YearMonth::valid($yearMonth, $min, $max) );
}
function valid_Provider() {
return [
'test 1' => [ '', '', '', '' ],
];
}
}
ia Doc