- implode: documentation ( source)
- strrev: documentation ( source)
<?php
class LuckyNumbers
{
public function sumUp(array $digitsOfNumber1, array $digitsOfNumber2): int
{
$convNum1 = (int) implode($digitsOfNumber1);
$convNum2 = (int) implode($digitsOfNumber2);
return $convNum1+ $convNum2;
throw new \BadFunctionCallException("Implement the function");
}
public function isPalindrome(int $number): bool
{
// Reversing steps:-
$numberString = (string) $number;
$reverseNumberString = strrev($numberString);
$reverseNumber = (int) $reverseNumberString;
return $number == $reverseNumber;
throw new \BadFunctionCallException("Implement the function");
}
public function validate(string $input): string
{
if ($input <= 0) {
echo "Must be a whole number larger than 0";
}
if ($input == '') {
echo "Required field";
}
}
}
$lucky_numbers = new LuckyNumbers();
$lucky_numbers->validate('123');