/iaLib/ia_examples/ia/Date/DateFormatter_example.php
<?php
$ia_example = [
'title' => 'ia\Date\DateFormatter', // fully qualified className
'summary' => '', // class summary
'full_example' => '', // full usage example, relative path from ia_examples, blank '' not shown.
'example_file' => 'code/ia/Date/DateFormatter_example_code.php', // method by method example, blank '' not shown.
];
include( __DIR__ . '/../../template/ia_example_class.php');
/iaLib/ia_examples/code/ia/Date/DateFormatter_example_code.php
use ia\Date\DateFormatter;
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">';
///////// DateFormatter::ymd_dateTime(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_ymd_dateTime'><b>DateFormatter::ymd_dateTime(<span class="type">mixed</span> \$anyDate <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\DateFormatter", "ymd_dateTime")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>DateFormatter::ymd_dateTime(); ->
DOCUMENT_EXAMPLE;
/// run ///
echo DateFormatter::ymd_dateTime();
echo '</ol>';
///////// DateFormatter::ymd_date(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_ymd_date'><b>DateFormatter::ymd_date(<span class="type">mixed</span> \$anyDate <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\DateFormatter", "ymd_date")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>DateFormatter::ymd_date(); ->
DOCUMENT_EXAMPLE;
/// run ///
echo DateFormatter::ymd_date();
echo '</ol>';
///////// DateFormatter::short_dateTime(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_short_dateTime'><b>DateFormatter::short_dateTime(<span class="type">mixed</span> \$anyDate <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\DateFormatter", "short_dateTime")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>DateFormatter::short_dateTime(); ->
DOCUMENT_EXAMPLE;
/// run ///
echo DateFormatter::short_dateTime();
echo '</ol>';
///////// DateFormatter::short_date(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_short_date'><b>DateFormatter::short_date(<span class="type">mixed</span> \$anyDate <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\DateFormatter", "short_date")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>DateFormatter::short_date(); ->
DOCUMENT_EXAMPLE;
/// run ///
echo DateFormatter::short_date();
echo '</ol>';
///////// DateFormatter::dateFormat(); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_dateFormat'><b>DateFormatter::dateFormat(<span class="type">string \$format The</span> \$format <span class="default">= 'd/M/Y'</span>, <span class="type">mixed</span> \$anyDate <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Date\DateFormatter", "dateFormat")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>DateFormatter::dateFormat(); ->
DOCUMENT_EXAMPLE;
/// run ///
echo DateFormatter::dateFormat();
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\DateFormatter;
use PHPUnit\Framework\TestCase;
class DateFormatterTest extends TestCase {
/**
* @dataProvider ymd_dateTime_Provider
*
*/
public function test_ymd_dateTime($anyDate , $expected) {
$this->assertEquals($expected, DateFormatter::ymd_dateTime($anyDate) );
}
function ymd_dateTime_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider ymd_date_Provider
*
*/
public function test_ymd_date($anyDate , $expected) {
$this->assertEquals($expected, DateFormatter::ymd_date($anyDate) );
}
function ymd_date_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider short_dateTime_Provider
*
*/
public function test_short_dateTime($anyDate , $expected) {
$this->assertEquals($expected, DateFormatter::short_dateTime($anyDate) );
}
function short_dateTime_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider short_date_Provider
*
*/
public function test_short_date($anyDate , $expected) {
$this->assertEquals($expected, DateFormatter::short_date($anyDate) );
}
function short_date_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider dateFormat_Provider
*
*/
public function test_dateFormat($format, $anyDate , $expected) {
$this->assertEquals($expected, DateFormatter::dateFormat($format, $anyDate) );
}
function dateFormat_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
}
ia Doc