Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Character::isLetter() #833

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions classes/phing/system/lang/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,12 @@
*/
class Character
{

// this class might be extended with plenty of ordinal char constants
// and the like to support the multibyte aware datatype (char) in php
// in form of an object.
// anyway just a thought

/**
* @param $char
* @return bool
*/
public static function isLetter($char)
{
if (strlen($char) !== 1) {
$char = 0;
}

$char = (int) ord($char);

if ($char >= ord('A') && $char <= ord('Z')) {
return true;
}

if ($char >= ord('a') && $char <= ord('z')) {
return true;
}

return false;
return strlen($char) === 1 && ctype_alpha($char);
}
}