/** * Spell a number. * * @param int $number Number to spelling. * @param string $type Tye type of spelling. * * @return string */ public function spell($number, $type = self::SPELLING_NUMBER) { // Split numbers in lands (eg. *100.000* should be [ 0, 100 ]) $numberLands = static::getNumberLands($number); $numberLandsSpelled = []; // Process each number lands and get a raw spelled term. // Eg. *1.002* should be (reversed) [ 'two', 'one' ]. foreach ($numberLands as $numberLandKey => $numberLand) { // Process the number in current land, getting it simplified spelling. $numberLandSpelled = $this->locale->simple($numberLands[$numberLandKey]); // Numbers that can't be spelled naturally should be ignored. // A good example is *zero*, that will be processed only on formatter. if ($numberLandSpelled === null) { continue; } // Store the spelled number in the current land. $numberLandsSpelled[$numberLandKey] = $numberLandSpelled; } /** @var int[] $numberLands */ return $this->locale->format($this->locale, $numberLandsSpelled, $numberLands, $type); }