1. Go to this page and download the library: Download milantex/tpc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
# See the definition of the $forename property in the Student class (regex)
# Since the text above is not a valid forename format, it will not be set
$s->setForename('Not a valid name'); # This value is not valid
echo '<pre>' . print_r($s, true) . '</pre>';
# Almost all data that follow is valid (forename, surname and birthday),
# but the year and the index are not. These will not be set to new values.
$s->setForename('Pera')
->setSurname('Peric')
->setBirthDay('1991-04-30')
->setYearOfEnrollment(208) # This value is not valid
->setIndex(2083321); # This value is not valid
echo '<pre>' . print_r($s, true) . '</pre>';
# Tthis time the date will not be set, because it is impossible (May 31st).
$s->setBirthDay('1991-04-31'); # There is no April 31st in the calendar
echo '<pre>' . print_r($s, true) . '</pre>';
namespace Milantex\TPC\Types;
use Milantex\TPC\TypeInterface;
class FloatType implements TypeInterface {
private $min = \PHP_INT_MIN; # PHP_FLOAT_MIN will be available 7.2+
private $max = \PHP_INT_MAX; # PHP_FLOAT_MAX will be available 7.2+
public function __construct(\stdClass $tags) {
if (\property_exists($tags, 'min') && \is_double($tags->min)) {
$this->min = $tags->min;
}
if (\property_exists($tags, 'max') && \is_double($tags->max)) {
$this->max = $tags->max;
}
}
public function isValid($value) : bool {
if (!\is_double($value)) {
return false;
}
return $this->min <= $value && $value <= $this->max;
}
}
html
<pre>
Milantex\SampleApp\Student Object
(
[forename:protected] => Milan
[surname:protected] => Tair
[birthDay:protected] => 1988-03-24
[index:protected] => 2008213514
[yearOfEnrollment:protected] => 2008
)
</pre>
html
<pre>
Milantex\SampleApp\Student Object
(
[forename:protected] => Milan
[surname:protected] => Tair
[birthDay:protected] => 1988-03-24
[index:protected] => 2008213514
[yearOfEnrollment:protected] => 2008
)
</pre>