protected function getChoiceBySelection($selection)
    {
        preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
        if (count($matches) < 2) {
            return;
        }
        $username = $matches[1];
        foreach ($this->choices as $item) {
            if ($item->getUsername() === $username) {
                return $item;
            }
        }

        return;
    }
protected function getChoiceBySelection($selection)
    {
        preg_match('/^[^(]+\(([^\)]+)\)$/', $selection, $matches);
        if (count($matches) < 2) {
            return;
        }
        $username = $matches[1];
        foreach ($this->choices as $item) {
            if ($item->getUsername() === $username) {
                return $item;
            }
        }

        return;
    }
protected function getChoiceBySelection ( $ selection ) { preg_match ( '/^[^(]+\(([^\)]+)\)$/' , $ selection , $ matches ) ; if ( count ( $ matches ) < 2 ) { return ; } $ username = $ matches [ 1 ] ; foreach ( $ this -> choices as $ item ) { if ( $ item -> getUsername ( ) === $ username ) { return $ item ; } } return ; }
Find User by username

@param string $username

@return User
Find User by username