@param string $phone

@return UserInterface
178561
public function setPhone($phone)
    {
        if (!empty($phone) && is_string($phone) && ctype_print($phone)) {
            $this->phone = trim($phone);
        }

        return $this;
    }
1350882
private function phoneValidate($phone)
    {
        $result = null;
        $phone  = trim($phone);
        if (!empty($phone)) {
            if (!$this->phoneHelper) {
                $this->phoneHelper = new PhoneNumberHelper();
            }
            try {
                $phone = $this->phoneHelper->format($phone);
                if (!empty($phone)) {
                    $result = $phone;
                }
            } catch (\Exception $e) {
            }
        }

        return $result;
    }
1001825
public function getMobilePhoneNumberFromUser($user = null)
    {
        if (!$user)
            $user = $this->getLoggedInUser();
        // It may just be an ID.
        if (is_numeric($user)) {
            $userManager = $this->container->get('fos_user.user_manager');
            $user = $userManager->findUserBy(array('id' => $user));
        }
        // Or string?
        if (is_string($user)) {
            $userManager = $this->container->get('fos_user.user_manager');
            $user = $userManager->findUserBy(array('username' => $user));
        }

        if (is_object($user) && method_exists($user, 'getMobilePhoneNumber'))
            return $user->getMobilePhoneNumber();
        if (is_object($user) && method_exists($user, 'getPhoneNumber'))
            return $user->getPhoneNumber();
        return null;
    }
591255
public function setContact(\Sulu\Bundle\ContactBundle\Entity\ContactInterface $contact)
    {
        $this->contact = $contact;

        return $this;
    }
34747
public function getPhone() : ?string 
    {
        if ( ! $this->hasPhone()) {
            $this->setPhone($this->getDefaultPhone());
        }
        return $this->phone;
    }
1134975
private UserInterface fromUser(User user) {
        return new UserInterface(user.getId(), user.getUsername(), user.getIpAddress(),
            user.getEmail(), user.getData());
    }
388210
function(phone) {
      var user = this.getUser();
      if (user) {
        return this._q.when(user.updatePhone(phone));
      } else {
        return this._q.reject("Cannot update phone since there is no logged in user.");
      }
    }
887057
public function create(ModelInterface $model)
    {
        $user = $this->container->make(UserSingularity::class);

        $user
            ->setModel($model)
            ->boot();

        return $user;
    }
1323163
public function manage(User $user, Phone $phone)
    {
        switch ($phone->phoneable_type) {
            case User::class:
                return $user->id === $phone->phoneable_id;
            default:
                return $this->allowForRoleOnTeam($user, 'Coach', $phone->phoneable->team_id);
        }
    }
4506
private function convertUser(array $user) : UserInterface
    {
        $baseUser   = new BaseUser();
        $baseUser->setLoginName($user['login_name']);
        $baseUser->setLoginPassword($user['login_password']);
        $baseUser->setRoles($user['roles']);
        return $baseUser;
    }
270251
public function load($username): UserInterface
    {
        $grav = Grav::instance();
        /** @var UniformResourceLocator $locator */
        $locator = $grav['locator'];

        // force lowercase of username
        $username = mb_strtolower($username);

        $filename = 'account://' . $username . YAML_EXT;
        $path = $locator->findResource($filename) ?: $locator->findResource($filename, true, true);
        $file = CompiledYamlFile::instance($path);
        $content = (array)$file->content() + ['username' => $username, 'state' => 'enabled'];

        $userClass = $this->className;
        $callable = function() {
            $blueprints = new Blueprints;

            return $blueprints->get('user/account');
        };

        /** @var UserInterface $user */
        $user = new $userClass($content, $callable);
        $user->file($file);

        return $user;
    }
813500
public function getPhone(): string
    {
        $string = '';
        if ($this->userMeta->notification_phone !== null) {
            $phone = new UserMetaPhone($this->userMeta->notification_phone);
            $string = $phone->country . $phone->number;
        }
        return $string;
    }
234987
public function refreshUser(UserInterface $user)
    {
        $username                     = $user->getUsername();
        $this->cachedUsers[$username] = $this->userProvider->refreshUser($user);
        return $this->cachedUsers[$username];
    }
548620
private function addUserInterfaceNode(ArrayNodeDefinition $rootNode)
    {
        $validate = function (string $interface) {

            $class = new \ReflectionClass(\str_replace(':', '\\Entity\\', $interface));

            return !$class->implementsInterface(UserInterface::class);
        };

        $rootNode->children()->variableNode('user_provider')
            ->info('The user provider entity')
            ->isRequired()
            ->validate()
            ->ifTrue($validate)
            ->thenInvalid('%s isn\'t a valid user provider.')
            ->end()
            ->end();

        return $rootNode;
    }
1069333
public static function create(UserInterface $user): UserMetaInterface
    {
        /** @var AbstractUser $user */
        $user_meta = static::findOne(['user_id' => $user->id]);
        if ($user_meta instanceof UserMetaInterface) {
            return $user_meta;
        }
        $user_meta = new static([
            'user_id' => $user->id,
            'notification_email' => $user->email,
            'display_name' => $user->username,
        ]);
        (new UserMetaHandler($user_meta))->create();
        $user_meta->refresh();
        return $user_meta;
    }
1037370
public function getUserRole(UserInterface $user)
    {
        $currentRole = '';
        $userRoles = $user->getRoles();

        if (in_array($userRoles[0], $this->getOrderedRoles())) {
            $currentRole = $userRoles[0];
        }

        return $currentRole;
    }
301595
public function cleanPhone($phone)
    {
        $response = $this->query($this->prepareUri('clean/phone'), [$phone]);
        $result = $this->populate(new Phone, $response);
        if (!$result instanceof Phone) {
            throw new RuntimeException('Unexpected populate result: ' . get_class($result). '. Expected: ' . Phone::class);
        }
        return $result;
    }