/** * Validates the given value * * @param mixed $value The value to validate * @return String|NULL Any errors encountered */ protected function process($value) { if (is_bool($value) || is_int($value) || is_float($value) || is_null($value)) { $value = (string) $value; } if (!is_string($value)) { return "Must be a string"; } if (strlen($value) > $this->length) { return "Must not be longer than " . $this->length . " " . \r8\Words::pluralize("character", $this->length); } }
public function testOrdinal() { $this->assertEquals("1st", \r8\Words::ordinal(1)); $this->assertEquals("2nd", \r8\Words::ordinal(2)); $this->assertEquals("3rd", \r8\Words::ordinal(3)); $this->assertEquals("4th", \r8\Words::ordinal(4)); $this->assertEquals("5th", \r8\Words::ordinal(5)); $this->assertEquals("6th", \r8\Words::ordinal(6)); $this->assertEquals("7th", \r8\Words::ordinal(7)); $this->assertEquals("8th", \r8\Words::ordinal(8)); $this->assertEquals("9th", \r8\Words::ordinal(9)); $this->assertEquals("10th", \r8\Words::ordinal(10)); $this->assertEquals("11th", \r8\Words::ordinal(11)); $this->assertEquals("12th", \r8\Words::ordinal(12)); $this->assertEquals("13th", \r8\Words::ordinal(13)); $this->assertEquals("14th", \r8\Words::ordinal(14)); $this->assertEquals("15th", \r8\Words::ordinal(15)); $this->assertEquals("16th", \r8\Words::ordinal(16)); $this->assertEquals("17th", \r8\Words::ordinal(17)); $this->assertEquals("18th", \r8\Words::ordinal(18)); $this->assertEquals("19th", \r8\Words::ordinal(19)); $this->assertEquals("20th", \r8\Words::ordinal(20)); $this->assertEquals("21st", \r8\Words::ordinal(21)); $this->assertEquals("22nd", \r8\Words::ordinal(22)); $this->assertEquals("23rd", \r8\Words::ordinal(23)); $this->assertEquals("24th", \r8\Words::ordinal(24)); $this->assertEquals("25th", \r8\Words::ordinal(25)); $this->assertEquals("30th", \r8\Words::ordinal(30)); $this->assertEquals("-1st", \r8\Words::ordinal(-1)); $this->assertEquals("-2nd", \r8\Words::ordinal(-2)); $this->assertEquals("-3rd", \r8\Words::ordinal(-3)); $this->assertEquals("-4th", \r8\Words::ordinal(-4)); $this->assertEquals("-5th", \r8\Words::ordinal(-5)); $this->assertEquals("-9th", \r8\Words::ordinal(-9)); $this->assertEquals("-10th", \r8\Words::ordinal(-10)); }