/iaLib/ia_examples/ia/Math/BcMath_example.php
<?php
$ia_example = [
'title' => 'ia\Math\BcMath', // fully qualified className
'summary' => '', // class summary
'full_example' => '', // full usage example, relative path from ia_examples, blank '' not shown.
'example_file' => 'code/ia/Math/BcMath_example_code.php', // method by method example, blank '' not shown.
];
include( __DIR__ . '/../../template/ia_example_class.php');
/iaLib/ia_examples/code/ia/Math/BcMath_example_code.php
use ia\Math\BcMath;
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">';
///////// BcMath::bcscale(null /* == */); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcscale'><b>BcMath::bcscale(<span class="type"></span> \$scale) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcscale")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcscale(null /* == */);
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
BcMath::bcscale(null /* == */)
);
echo "</pre>";
echo '</ol>';
///////// BcMath::bcmulArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcmulArray'><b>BcMath::bcmulArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcmulArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcmulArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcmulArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcdivArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcdivArray'><b>BcMath::bcdivArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcdivArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcdivArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcdivArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcaddArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcaddArray'><b>BcMath::bcaddArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcaddArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcaddArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcaddArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcsubArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcsubArray'><b>BcMath::bcsubArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcsubArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcsubArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcsubArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcmaxArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcmaxArray'><b>BcMath::bcmaxArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcmaxArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcmaxArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcmaxArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcminArray(['a' => '1', 'b' => '2', 'c' => 3]); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcminArray'><b>BcMath::bcminArray(<span class="type">array</span> \$arr, <span class="type">int</span> \$scale <span class="default">= null</span>) <span>: string</span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcminArray")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcminArray(['a' => '1', 'b' => '2', 'c' => 3]); ->
DOCUMENT_EXAMPLE;
/// run ///
echo BcMath::bcminArray(['a' => '1', 'b' => '2', 'c' => 3]);
echo '</ol>';
///////// BcMath::bcformat(null /* == */); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcformat'><b>BcMath::bcformat(<span class="type"></span> \$number, <span class="type"></span> \$decimals <span class="default">= 2</span>, <span class="type"></span> \$dec_point <span class="default">= '.'</span>, <span class="type"></span> \$thousandsSep <span class="default">= ','</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcformat")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcformat(null /* == */);
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
BcMath::bcformat(null /* == */)
);
echo "</pre>";
echo '</ol>';
///////// BcMath::bcround(null /* == */); //////////////////////////////////////////////////
echo <<< FUNCTIONDEF
<li id='u_bcround'><b>BcMath::bcround(<span class="type"></span> \$number, <span class="type"></span> \$precision <span class="default">= null</span>) <span>: </span></b>
FUNCTIONDEF;
echo "<pre class='docBlock'>".DocumentIt::methodDocBlockProtected("ia\Math\BcMath", "bcround")."</pre>";
echo "<ol class='usage'>";
/// display ///
echo <<< DOCUMENT_EXAMPLE
<li>BcMath::bcround(null /* == */);
-> </b><br><pre>
DOCUMENT_EXAMPLE;
/// run ///
print_r(
BcMath::bcround(null /* == */)
);
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\Math\BcMath;
use PHPUnit\Framework\TestCase;
class BcMathTest extends TestCase {
/**
* @dataProvider bcscale_Provider
*
*/
public function test_bcscale($scale , $expected) {
$this->assertEquals($expected, BcMath::bcscale($scale) );
}
function bcscale_Provider() {
return [
'test 1' => [ '', '' ],
];
}
/**
* @dataProvider bcmulArray_Provider
*
*/
public function test_bcmulArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcmulArray($arr, $scale) );
}
function bcmulArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcdivArray_Provider
*
*/
public function test_bcdivArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcdivArray($arr, $scale) );
}
function bcdivArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcaddArray_Provider
*
*/
public function test_bcaddArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcaddArray($arr, $scale) );
}
function bcaddArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcsubArray_Provider
*
*/
public function test_bcsubArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcsubArray($arr, $scale) );
}
function bcsubArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcmaxArray_Provider
*
*/
public function test_bcmaxArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcmaxArray($arr, $scale) );
}
function bcmaxArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcminArray_Provider
*
*/
public function test_bcminArray($arr, $scale , $expected) {
$this->assertEquals($expected, BcMath::bcminArray($arr, $scale) );
}
function bcminArray_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
/**
* @dataProvider bcformat_Provider
*
*/
public function test_bcformat($number, $decimals, $dec_point, $thousandsSep , $expected) {
$this->assertEquals($expected, BcMath::bcformat($number, $decimals, $dec_point, $thousandsSep) );
}
function bcformat_Provider() {
return [
'test 1' => [ '', '', '', '', '' ],
];
}
/**
* @dataProvider bcround_Provider
*
*/
public function test_bcround($number, $precision , $expected) {
$this->assertEquals($expected, BcMath::bcround($number, $precision) );
}
function bcround_Provider() {
return [
'test 1' => [ '', '', '' ],
];
}
}
ia Doc