function testCutoff() { $result = CoreUtils::cutoff('This is a long string', 10); self::assertEquals(10, CoreUtils::length($result)); self::assertEquals('This is a…', $result); }
$Group = array('groupid' => $GroupID); } else { $CGDb->where('groupid', $Group['groupid'])->update('colorgroups', $data); } $origColors = $adding ? null : ColorGroups::getColors($Group['groupid']); $recvColors = (new Input('Colors', 'json', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => "Missing list of {$color}s", Input::ERROR_INVALID => "List of {$color}s is invalid"))))->out(); $colors = array(); foreach ($recvColors as $part => $c) { $append = array('order' => $part); $index = "(index: {$part})"; if (empty($c['label'])) { Response::fail("You must specify a {$color} name {$index}"); } $label = CoreUtils::trim($c['label']); CoreUtils::checkStringValidity($label, "{$Color} {$index} name", INVERSE_PRINTABLE_ASCII_PATTERN); $ll = CoreUtils::length($label); if ($ll < 3 || $ll > 30) { Response::fail("The {$color} name must be between 3 and 30 characters in length {$index}"); } $append['label'] = $label; if (empty($c['hex'])) { Response::fail("You must specify a {$color} code {$index}"); } $hex = CoreUtils::trim($c['hex']); if (!$HEX_COLOR_REGEX->match($hex, $_match)) { Response::fail("HEX {$color} is in an invalid format {$index}"); } $append['hex'] = '#' . strtoupper($_match[1]); $colors[] = $append; } if (!$adding) {