コード例 #1
0
 public function testExplodeNameSpanish()
 {
     $exploder = new NameExploder('es');
     $name = $exploder->explode('Sr Alistair Shaw');
     $this->assertEquals('Sr', (string) $name->title());
     $this->assertEquals('Alistair', $name->firstName());
     $this->assertEquals('', $name->middleInitial());
     $this->assertEquals('Shaw', $name->lastName());
     $this->assertEquals('Sr Alistair Shaw', (string) $name);
     $name = $exploder->explode('Señor Alistair M Shaw');
     $this->assertEquals('Sr', $name->title());
     $this->assertEquals('Alistair', $name->firstName());
     $this->assertEquals('M', $name->middleInitial());
     $this->assertEquals('Shaw', $name->lastName());
     $this->assertEquals('Sr Alistair M Shaw', (string) $name);
     $name = $exploder->explode('Señorita Alistair Shaw');
     $this->assertEquals('Srta', $name->title());
     $this->assertEquals('Alistair', $name->firstName());
     $this->assertEquals('', $name->middleInitial());
     $this->assertEquals('Shaw', $name->lastName());
     $this->assertEquals('Srta Alistair Shaw', (string) $name);
 }
コード例 #2
0
ファイル: Name.php プロジェクト: alistairshaw/vendirun-plugin
 /**
  * @param $fullName
  * @return Name
  */
 public static function fromFullName($fullName)
 {
     $nameExploder = new NameExploder();
     $name = $nameExploder->explode($fullName);
     return new self($name->firstName(), $name->middleInitial(), $name->lastName(), $name->title());
 }