private function parseName($key=null)
	{
		$name = $this->get('name');
		if ($name)
		{
			$firstname  = "";
			$middlename = "";
			$lastname   = "";

			$words = array_map('trim', explode(' ', $this->get('name')));
			$count = count($words);

			if ($count == 1)
			{
				$firstname = $words[0];
			}
			else if ($count == 2)
			{
				$firstname = $words[0];
				$lastname  = $words[1];
			}
			else if ($count == 3)
			{
				$firstname  = $words[0];
				$middlename = $words[1];
				$lastname   = $words[2];
			}
			else
			{
				$firstname  = $words[0];
				$lastname   = $words[$count-1];
				$middlename = $words[1];

				for ($i = 2; $i < $count-1; $i++)
				{
					$middlename .= ' ' . $words[$i];
				}
			}
			switch ($key)
			{
				case 'givenName':
					return trim($firstname);
					break;
				case 'middleName':
					return trim($middlename);
					break;
				case 'surname':
					return trim($lastname);
					break;
				default:
					return '';
			}
		}
	}
private function parseName($key=null)
	{
		$name = $this->get('name');
		if ($name)
		{
			$firstname  = "";
			$middlename = "";
			$lastname   = "";

			$words = array_map('trim', explode(' ', $this->get('name')));
			$count = count($words);

			if ($count == 1)
			{
				$firstname = $words[0];
			}
			else if ($count == 2)
			{
				$firstname = $words[0];
				$lastname  = $words[1];
			}
			else if ($count == 3)
			{
				$firstname  = $words[0];
				$middlename = $words[1];
				$lastname   = $words[2];
			}
			else
			{
				$firstname  = $words[0];
				$lastname   = $words[$count-1];
				$middlename = $words[1];

				for ($i = 2; $i < $count-1; $i++)
				{
					$middlename .= ' ' . $words[$i];
				}
			}
			switch ($key)
			{
				case 'givenName':
					return trim($firstname);
					break;
				case 'middleName':
					return trim($middlename);
					break;
				case 'surname':
					return trim($lastname);
					break;
				default:
					return '';
			}
		}
	}
private function parseName ( $ key = null ) { $ name = $ this -> get ( 'name' ) ; if ( $ name ) { $ firstname = "" ; $ middlename = "" ; $ lastname = "" ; $ words = array_map ( 'trim' , explode ( ' ' , $ this -> get ( 'name' ) ) ) ; $ count = count ( $ words ) ; if ( $ count == 1 ) { $ firstname = $ words [ 0 ] ; } else if ( $ count == 2 ) { $ firstname = $ words [ 0 ] ; $ lastname = $ words [ 1 ] ; } else if ( $ count == 3 ) { $ firstname = $ words [ 0 ] ; $ middlename = $ words [ 1 ] ; $ lastname = $ words [ 2 ] ; } else { $ firstname = $ words [ 0 ] ; $ lastname = $ words [ $ count - 1 ] ; $ middlename = $ words [ 1 ] ; for ( $ i = 2 ; $ i < $ count - 1 ; $ i ++ ) { $ middlename .= ' ' . $ words [ $ i ] ; } } switch ( $ key ) { case 'givenName' : return trim ( $ firstname ) ; break ; case 'middleName' : return trim ( $ middlename ) ; break ; case 'surname' : return trim ( $ lastname ) ; break ; default : return '' ; } } }
Parse a users name and set the name parts on the instance

@return void
Parse a users name and set the name parts on the instance