method set_info documentation in bbn\Entities\People

function($st, $email = false, $portable = false) { if (is_array($st)) { $fn = $st; if (!isset($fn['prenom']) && !isset($fn['civilite'])) { $st = $fn['nom']; } } else{ $fn = []; if ($email) { $fn['email'] = $email; } if ($portable) { $fn['portable'] = $portable; } } if (is_string($st) && !empty($st)) { $fn['prenom'] = ''; // Import: recherche, suppression et retour de commentaires entre parentheses preg_match('/\(([^\)]+)/', $st, $m); if (count($m) === 2) { $st = substr($st, 0, strpos($st, $m[0])); $fn['comment'] = $m[1]; } // array_values reinitializes the keys after array_filter $fullname = array_values(\bbn\X::removeEmpty(explode(" ",$st), 1)); if (isset($fullname[0])) { if (isset(self::$civs[\bbn\Str::changeCase($fullname[0], 'upper')])) { $fn['civilite'] = self::$civs[\bbn\Str::changeCase($fullname[0], 'upper')]; array_shift($fullname); // Cas M MME if (isset($fullname[0], self::$civs[\bbn\Str::changeCase($fullname[0], 'upper')])) { $fn['civilite'] = 'M/MME'; array_shift($fullname); } if (!isset($fullname[0])) { return false; } } // Cas STE if (isset($fullname[0]) && in_array($fullname[0], self::$stes)) { $fn['nom'] = implode(" ", $fullname); } elseif (( count($fullname) === 3 ) && strlen($fullname[0]) <= 3) { $fn['nom'] = \bbn\Str::changeCase(\bbn\Str::changeCase($fullname[0].' '.$fullname[1], 'lower')); $fn['prenom'] = \bbn\Str::changeCase(\bbn\Str::changeCase($fullname[2], 'lower')); } elseif (count($fullname) > 2) { if (isset($fn['civilite'])) { $fn['prenom'] = \bbn\Str::changeCase(\bbn\Str::changeCase(array_pop($fullname), 'lower')); $fn['nom'] = \bbn\Str::changeCase(\bbn\Str::changeCase(implode(" ", $fullname), 'lower')); } else{ $fn['nom'] = \bbn\Str::changeCase(\bbn\Str::changeCase(implode(" ", $fullname), 'lower')); } } elseif (count($fullname) < 2 || !isset($fullname[1])) { $fn['nom'] = $fullname[0]; } else{ $fn['prenom'] = \bbn\Str::changeCase(\bbn\Str::changeCase($fullname[1], 'lower')); $fn['nom'] = \bbn\Str::changeCase(\bbn\Str::changeCase($fullname[0], 'lower')); } } } if (is_array($fn)) { if (!isset($fn['prenom'])) { $fn['prenom'] = ''; } if (!isset($fn['civilite'])) { $fn['civilite'] = empty($fn['prenom']) ? null : 'M'; } $fn['fnom'] = $this->fnom($fn); if (isset($fn['email']) && !\bbn\Str::isEmail($fn['email'])) { unset($fn['email']); } if (isset($fn['tel'])) { $fn['portable'] = $fn['tel']; unset($fn['tel']); } if (isset($fn['portable'])) { $fn['portable'] = \bbn\Str::getNumbers($fn['portable']); if (strlen($fn['portable']) > 10 && strpos($fn['portable'], '33') === 0) { $fn['portable'] = substr($fn['portable'], 2); } if (strlen($fn['portable']) === 9 && strpos($fn['portable'], '0') !== 0) { $fn['portable'] = '0'.$fn['portable']; } if (strlen($fn['portable']) !== 10) { unset($fn['portable']); } } if (!isset($fn['nom'])) { $fn = []; } return $fn; } return false; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.