/** * This method initializes all static vars which contain complex datatypes. * It acts somewhat like a static block in Java. Since PHP does not support this principle, the method * is called from the constructor. Because of that you can not access the static vars unless there * exists at least one object of the class. */ private static function __static() { if (!self::$initialized) { self::$initialized = true; self::$elements = array(new PWElement('a', self::VOWEL), new PWElement('ae', self::VOWEL | self::DIPHTHONG), new PWElement('ah', self::VOWEL | self::DIPHTHONG), new PWElement('ai', self::VOWEL | self::DIPHTHONG), new PWElement('b', self::CONSONANT), new PWElement('c', self::CONSONANT), new PWElement('ch', self::CONSONANT | self::DIPHTHONG), new PWElement('d', self::CONSONANT), new PWElement('e', self::VOWEL), new PWElement('ee', self::VOWEL | self::DIPHTHONG), new PWElement('ei', self::VOWEL | self::DIPHTHONG), new PWElement('f', self::CONSONANT), new PWElement('g', self::CONSONANT), new PWElement('gh', self::CONSONANT | self::DIPHTHONG | self::NOT_FIRST), new PWElement('h', self::CONSONANT), new PWElement('i', self::VOWEL), new PWElement('ie', self::VOWEL | self::DIPHTHONG), new PWElement('j', self::CONSONANT), new PWElement('k', self::CONSONANT), new PWElement('l', self::CONSONANT), new PWElement('m', self::CONSONANT), new PWElement('n', self::CONSONANT), new PWElement('ng', self::CONSONANT | self::DIPHTHONG | self::NOT_FIRST), new PWElement('o', self::VOWEL), new PWElement('oh', self::VOWEL | self::DIPHTHONG), new PWElement('oo', self::VOWEL | self::DIPHTHONG), new PWElement('p', self::CONSONANT), new PWElement('ph', self::CONSONANT | self::DIPHTHONG), new PWElement('qu', self::CONSONANT | self::DIPHTHONG), new PWElement('r', self::CONSONANT), new PWElement('s', self::CONSONANT), new PWElement('sh', self::CONSONANT | self::DIPHTHONG), new PWElement('t', self::CONSONANT), new PWElement('th', self::CONSONANT | self::DIPHTHONG), new PWElement('u', self::VOWEL), new PWElement('v', self::CONSONANT), new PWElement('w', self::CONSONANT), new PWElement('x', self::CONSONANT), new PWElement('y', self::CONSONANT), new PWElement('z', self::CONSONANT)); self::$pw_ambiguous = 'B8G6I1l0OQDS5Z2'; self::$pw_symbols = "!\"#\$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; self::$pw_digits = '0123456789'; self::$pw_uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; self::$pw_lowers = 'abcdefghijklmnopqrstuvwxyz'; self::$pw_vowels = '01aeiouyAEIOUY'; } }
/** * Disallow certain special chars * @param array $symbols */ public function blacklistSymbol(array $symbols) { foreach ($symbols as $symbol) { if (!preg_match('/' . preg_quote($symbol) . '/', self::$pw_symbols)) { return; } } $symbolArray = str_split(self::$pw_symbols); foreach ($symbols as $symbol) { $index = array_search($symbol, $symbolArray); unset($symbolArray[$index]); } self::$pw_symbols = implode('', $symbolArray); }