Skip to content

Instantly share code, notes, and snippets.

@Vusys
Created July 7, 2020 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vusys/8736a30524c162830586e2145d787786 to your computer and use it in GitHub Desktop.
Save Vusys/8736a30524c162830586e2145d787786 to your computer and use it in GitHub Desktop.
<?php
class keyOne
{
public function canType($input)
{
if ($input == ".") {
return true;
}
if (strtolower($input) == ".") {
return true;
}
if ($input == ",") {
return true;
}
if (strtolower($input) == ",") {
return true;
}
if ($input == "?") {
return true;
}
if (strtolower($input) == "?") {
return true;
}
if ($input == "!") {
return true;
}
if (strtolower($input) == "!") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == ".") {
if ($isSuccession) {
return '_1';
} else {
return '1';
}
}
if (strtolower($input) != $input && strtolower($input) == ".") {
if ($isSuccession) {
return '_#1';
} else {
return '#1';
}
}
if ($input == ",") {
if ($isSuccession) {
return '_11';
} else {
return '11';
}
}
if (strtolower($input) != $input && strtolower($input) == ",") {
if ($isSuccession) {
return '_#11';
} else {
return '#11';
}
}
if ($input == "?") {
if ($isSuccession) {
return '_111';
} else {
return '111';
}
}
if (strtolower($input) != $input && strtolower($input) == "?") {
if ($isSuccession) {
return '_#111';
} else {
return '#111';
}
}
if ($input == "!") {
if ($isSuccession) {
return '_1111';
} else {
return '1111';
}
}
if (strtolower($input) != $input && strtolower($input) == "!") {
if ($isSuccession) {
return '_#1111';
} else {
return '#1111';
}
}
}
}
class keyTwo
{
public function canType($input)
{
if ($input == "a") {
return true;
}
if (strtolower($input) == "a") {
return true;
}
if ($input == "b") {
return true;
}
if (strtolower($input) == "b") {
return true;
}
if ($input == "c") {
return true;
}
if (strtolower($input) == "c") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "a") {
if ($isSuccession) {
return '_2';
} else {
return '2';
}
}
if (strtolower($input) != $input && strtolower($input) == "a") {
if ($isSuccession) {
return '_#2';
} else {
return '#2';
}
}
if ($input == "b") {
if ($isSuccession) {
return '_22';
} else {
return '22';
}
}
if (strtolower($input) != $input && strtolower($input) == "b") {
if ($isSuccession) {
return '_#22';
} else {
return '#22';
}
}
if ($input == "c") {
if ($isSuccession) {
return '_222';
} else {
return '222';
}
}
if (strtolower($input) != $input && strtolower($input) == "c") {
if ($isSuccession) {
return '_#222';
} else {
return '#222';
}
}
}
}
class keyThree
{
public function canType($input)
{
if ($input == "d") {
return true;
}
if (strtolower($input) == "d") {
return true;
}
if ($input == "e") {
return true;
}
if (strtolower($input) == "e") {
return true;
}
if ($input == "f") {
return true;
}
if (strtolower($input) == "f") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "d") {
if ($isSuccession) {
return '_3';
} else {
return '3';
}
}
if (strtolower($input) != $input && strtolower($input) == "d") {
if ($isSuccession) {
return '_#3';
} else {
return '#3';
}
}
if ($input == "e") {
if ($isSuccession) {
return '_33';
} else {
return '33';
}
}
if (strtolower($input) != $input && strtolower($input) == "e") {
if ($isSuccession) {
return '_#33';
} else {
return '#33';
}
}
if ($input == "f") {
if ($isSuccession) {
return '_333';
} else {
return '333';
}
}
if (strtolower($input) != $input && strtolower($input) == "f") {
if ($isSuccession) {
return '_#333';
} else {
return '#333';
}
}
}
}
class keyFour
{
public function canType($input)
{
if ($input == "g") {
return true;
}
if (strtolower($input) == "g") {
return true;
}
if ($input == "h") {
return true;
}
if (strtolower($input) == "h") {
return true;
}
if ($input == "i") {
return true;
}
if (strtolower($input) == "i") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "g") {
if ($isSuccession) {
return '_4';
} else {
return '4';
}
}
if (strtolower($input) != $input && strtolower($input) == "g") {
if ($isSuccession) {
return '_#4';
} else {
return '#4';
}
}
if ($input == "h") {
if ($isSuccession) {
return '_44';
} else {
return '44';
}
}
if (strtolower($input) != $input && strtolower($input) == "h") {
if ($isSuccession) {
return '_#44';
} else {
return '#44';
}
}
if ($input == "i") {
if ($isSuccession) {
return '_444';
} else {
return '444';
}
}
if (strtolower($input) != $input && strtolower($input) == "i") {
if ($isSuccession) {
return '_#444';
} else {
return '#444';
}
}
}
}
class keyFive
{
public function canType($input)
{
if ($input == "j") {
return true;
}
if (strtolower($input) == "j") {
return true;
}
if ($input == "k") {
return true;
}
if (strtolower($input) == "k") {
return true;
}
if ($input == "l") {
return true;
}
if (strtolower($input) == "l") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "j") {
if ($isSuccession) {
return '_5';
} else {
return '5';
}
}
if (strtolower($input) != $input && strtolower($input) == "j") {
if ($isSuccession) {
return '_#5';
} else {
return '#5';
}
}
if ($input == "k") {
if ($isSuccession) {
return '_55';
} else {
return '55';
}
}
if (strtolower($input) != $input && strtolower($input) == "k") {
if ($isSuccession) {
return '_#55';
} else {
return '#55';
}
}
if ($input == "l") {
if ($isSuccession) {
return '_555';
} else {
return '555';
}
}
if (strtolower($input) != $input && strtolower($input) == "l") {
if ($isSuccession) {
return '_#555';
} else {
return '#555';
}
}
}
}
class keySix
{
public function canType($input)
{
if ($input == "m") {
return true;
}
if (strtolower($input) == "m") {
return true;
}
if ($input == "n") {
return true;
}
if (strtolower($input) == "n") {
return true;
}
if ($input == "o") {
return true;
}
if (strtolower($input) == "o") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "m") {
if ($isSuccession) {
return '_6';
} else {
return '6';
}
}
if (strtolower($input) != $input && strtolower($input) == "m") {
if ($isSuccession) {
return '_#6';
} else {
return '#6';
}
}
if ($input == "n") {
if ($isSuccession) {
return '_66';
} else {
return '66';
}
}
if (strtolower($input) != $input && strtolower($input) == "n") {
if ($isSuccession) {
return '_#66';
} else {
return '#66';
}
}
if ($input == "o") {
if ($isSuccession) {
return '_666';
} else {
return '666';
}
}
if (strtolower($input) != $input && strtolower($input) == "o") {
if ($isSuccession) {
return '_#666';
} else {
return '#666';
}
}
}
}
class keySeven
{
public function canType($input)
{
if ($input == "p") {
return true;
}
if (strtolower($input) == "p") {
return true;
}
if ($input == "q") {
return true;
}
if (strtolower($input) == "q") {
return true;
}
if ($input == "r") {
return true;
}
if (strtolower($input) == "r") {
return true;
}
if ($input == "s") {
return true;
}
if (strtolower($input) == "s") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "p") {
if ($isSuccession) {
return '_7';
} else {
return '7';
}
}
if (strtolower($input) != $input && strtolower($input) == "p") {
if ($isSuccession) {
return '_#7';
} else {
return '#7';
}
}
if ($input == "q") {
if ($isSuccession) {
return '_77';
} else {
return '77';
}
}
if (strtolower($input) != $input && strtolower($input) == "q") {
if ($isSuccession) {
return '_#77';
} else {
return '#77';
}
}
if ($input == "r") {
if ($isSuccession) {
return '_777';
} else {
return '777';
}
}
if (strtolower($input) != $input && strtolower($input) == "r") {
if ($isSuccession) {
return '_#777';
} else {
return '#777';
}
}
if ($input == "s") {
if ($isSuccession) {
return '_7777';
} else {
return '7777';
}
}
if (strtolower($input) != $input && strtolower($input) == "s") {
if ($isSuccession) {
return '_#7777';
} else {
return '#7777';
}
}
}
}
class keyEight
{
public function canType($input)
{
if ($input == "t") {
return true;
}
if (strtolower($input) == "t") {
return true;
}
if ($input == "u") {
return true;
}
if (strtolower($input) == "u") {
return true;
}
if ($input == "v") {
return true;
}
if (strtolower($input) == "v") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "t") {
if ($isSuccession) {
return '_8';
} else {
return '8';
}
}
if (strtolower($input) != $input && strtolower($input) == "t") {
if ($isSuccession) {
return '_#8';
} else {
return '#8';
}
}
if ($input == "u") {
if ($isSuccession) {
return '_88';
} else {
return '88';
}
}
if (strtolower($input) != $input && strtolower($input) == "u") {
if ($isSuccession) {
return '_#88';
} else {
return '#88';
}
}
if ($input == "v") {
if ($isSuccession) {
return '_888';
} else {
return '888';
}
}
if (strtolower($input) != $input && strtolower($input) == "v") {
if ($isSuccession) {
return '_#888';
} else {
return '#888';
}
}
}
}
class keyNine
{
public function canType($input)
{
if ($input == "w") {
return true;
}
if (strtolower($input) == "w") {
return true;
}
if ($input == "x") {
return true;
}
if (strtolower($input) == "x") {
return true;
}
if ($input == "y") {
return true;
}
if (strtolower($input) == "y") {
return true;
}
if ($input == "z") {
return true;
}
if (strtolower($input) == "z") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "w") {
if ($isSuccession) {
return '_9';
} else {
return '9';
}
}
if (strtolower($input) != $input && strtolower($input) == "w") {
if ($isSuccession) {
return '_#9';
} else {
return '#9';
}
}
if ($input == "x") {
if ($isSuccession) {
return '_99';
} else {
return '99';
}
}
if (strtolower($input) != $input && strtolower($input) == "x") {
if ($isSuccession) {
return '_#99';
} else {
return '#99';
}
}
if ($input == "y") {
if ($isSuccession) {
return '_999';
} else {
return '999';
}
}
if (strtolower($input) != $input && strtolower($input) == "y") {
if ($isSuccession) {
return '_#999';
} else {
return '#999';
}
}
if ($input == "z") {
if ($isSuccession) {
return '_9999';
} else {
return '9999';
}
}
if (strtolower($input) != $input && strtolower($input) == "z") {
if ($isSuccession) {
return '_#9999';
} else {
return '#9999';
}
}
}
}
class keyAsterisk
{
public function canType($input)
{
if ($input == "'") {
return true;
}
if (strtolower($input) == "'") {
return true;
}
if ($input == "-") {
return true;
}
if (strtolower($input) == "-") {
return true;
}
if ($input == "+") {
return true;
}
if (strtolower($input) == "+") {
return true;
}
if ($input == "=") {
return true;
}
if (strtolower($input) == "=") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == "'") {
if ($isSuccession) {
return '_*';
} else {
return '*';
}
}
if (strtolower($input) != $input && strtolower($input) == "'") {
if ($isSuccession) {
return '_#*';
} else {
return '#*';
}
}
if ($input == "-") {
if ($isSuccession) {
return '_**';
} else {
return '**';
}
}
if (strtolower($input) != $input && strtolower($input) == "-") {
if ($isSuccession) {
return '_#**';
} else {
return '#**';
}
}
if ($input == "+") {
if ($isSuccession) {
return '_***';
} else {
return '***';
}
}
if (strtolower($input) != $input && strtolower($input) == "+") {
if ($isSuccession) {
return '_#***';
} else {
return '#***';
}
}
if ($input == "=") {
if ($isSuccession) {
return '_****';
} else {
return '****';
}
}
if (strtolower($input) != $input && strtolower($input) == "=") {
if ($isSuccession) {
return '_#****';
} else {
return '#****';
}
}
}
}
class keyZero
{
public function canType($input)
{
if ($input == " ") {
return true;
}
if (strtolower($input) == " ") {
return true;
}
}
public function typeCharacter($input, $isSuccession)
{
if ($input == " ") {
if ($isSuccession) {
return '_0';
} else {
return '0';
}
}
if (strtolower($input) != $input && strtolower($input) == " ") {
if ($isSuccession) {
return '_#0';
} else {
return '#0';
}
}
}
}
class bbcc40
{
public $output;
public function __construct($input)
{
$input = str_split($input);
$output = '';
$lastKey = '';
foreach ($input as $char) {
$keyOne = new keyOne();
$keyTwo = new keyTwo();
$keyThree = new keyThree();
$keyFour = new keyFour();
$keyFive = new keyFive();
$keySix = new keySix();
$keySeven = new keySeven();
$keyEight = new keyEight();
$keyNine = new keyNine();
$keyAsterisk = new keyAsterisk();
$keyZero = new keyZero();
if ($keyOne->canType($char)) {
$output .= $keyOne->typeCharacter($char, $lastKey == 'keyOne');
$lastKey = 'keyOne';
}
if ($keyTwo->canType($char)) {
$output .= $keyTwo->typeCharacter($char, $lastKey == 'keyTwo');
$lastKey = 'keyTwo';
}
if ($keyThree->canType($char)) {
$output .= $keyThree->typeCharacter($char, $lastKey == 'keyThree');
$lastKey = 'keyThree';
}
if ($keyFour->canType($char)) {
$output .= $keyFour->typeCharacter($char, $lastKey == 'keyFour');
$lastKey = 'keyFour';
}
if ($keyFive->canType($char)) {
$output .= $keyFive->typeCharacter($char, $lastKey == 'keyFive');
$lastKey = 'keyFive';
}
if ($keySix->canType($char)) {
$output .= $keySix->typeCharacter($char, $lastKey == 'keySix');
$lastKey = 'keySix';
}
if ($keySeven->canType($char)) {
$output .= $keySeven->typeCharacter($char, $lastKey == 'keySeven');
$lastKey = 'keySeven';
}
if ($keyEight->canType($char)) {
$output .= $keyEight->typeCharacter($char, $lastKey == 'keyEight');
$lastKey = 'keyEight';
}
if ($keyNine->canType($char)) {
$output .= $keyNine->typeCharacter($char, $lastKey == 'keyNine');
$lastKey = 'keyNine';
}
if ($keyAsterisk->canType($char)) {
$output .= $keyAsterisk->typeCharacter($char, $lastKey == 'keyAsterisk');
$lastKey = 'keyAsterisk';
}
if ($keyZero->canType($char)) {
$output .= $keyZero->typeCharacter($char, $lastKey == 'keyZero');
$lastKey = 'keyZero';
}
}
$this->output = $output;
}
}
function to_t9($input)
{
$bbcc = new bbcc40($input);
return $bbcc->output;
}
print to_t9('Hello World') . "\n"; //#4433555_5556660#96667775553
print to_t9('HELLO WORLD') . "\n"; //#44#33#555_#555#6660#9#666#777#555#3
print to_t9('abba feed high') . "\n"; //2_22_22_20333_33_33_3044_444_4_44
print to_t9('I love PHP') . "\n"; //#4440555666888330#7#44#7
print to_t9('there r 4 lights!') . "\n"; //844337773307770_0555444_4_44877771111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment