src/Maths/Arithmetic/Helper.php
public static function isHappyNumber($val, $iteration = 0)
    {
        if ($val==1) {
            return true;
        }
        if ($val>0 && $iteration<50) {
            $items = str_split((string) $val);
            $count = 0;
            foreach ($items as $item) {
                $count += pow($item, 2);
            }
            if ($count == 1) {
                return true;
            }
            return self::isHappyNumber($count, $iteration+1);
        }
        return false;
    }
public static function isHappyNumber($val, $iteration = 0)
    {
        if ($val==1) {
            return true;
        }
        if ($val>0 && $iteration<50) {
            $items = str_split((string) $val);
            $count = 0;
            foreach ($items as $item) {
                $count += pow($item, 2);
            }
            if ($count == 1) {
                return true;
            }
            return self::isHappyNumber($count, $iteration+1);
        }
        return false;
    }
Test if a number is an "happy number":

Starting with any positive integer,
replace the number by the sum of the squares of its digits, and repeat the process until
the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1.

@see     https://en.wikipedia.org/wiki/Happy_number
@param $val
@param int $iteration
@return bool