src/Employee.php
public function getWorkPhone()
    {
        if (!isset($this->workPhone)) {
            $wp = trim($this->getRawWorkPhone());
            if (empty($wp)) {
                $this->workPhone = null;
            } else {
                if (preg_match('/^\+?[-\d\s()]+/', $wp, $matches)) {
                    $wp = $matches[0];
                    $wp = trim(str_replace(['(', ')'], '', $wp));
                    if (strlen(str_replace(' ', '', $wp)) === 4) {
                        $wp = self::phonePrefixForExt($wp) . $wp;
                    }
                    if ($wp[0] !== '0' && $wp[0] !== '+') {
                        $wp = '08' . $wp;
                    }
                    $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
                    try {
                        $this->workPhone = $phoneUtil->parse($wp, 'SE');
                    } catch (\libphonenumber\NumberParseException $e) {
                        $this->workPhone = $this->getRawWorkPhone();
                    }
                } else {
                    $this->workPhone = $this->getRawWorkPhone();
                }
            }
        }
        return $this->workPhone;
    }
public function getWorkPhone()
    {
        if (!isset($this->workPhone)) {
            $wp = trim($this->getRawWorkPhone());
            if (empty($wp)) {
                $this->workPhone = null;
            } else {
                if (preg_match('/^\+?[-\d\s()]+/', $wp, $matches)) {
                    $wp = $matches[0];
                    $wp = trim(str_replace(['(', ')'], '', $wp));
                    if (strlen(str_replace(' ', '', $wp)) === 4) {
                        $wp = self::phonePrefixForExt($wp) . $wp;
                    }
                    if ($wp[0] !== '0' && $wp[0] !== '+') {
                        $wp = '08' . $wp;
                    }
                    $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
                    try {
                        $this->workPhone = $phoneUtil->parse($wp, 'SE');
                    } catch (\libphonenumber\NumberParseException $e) {
                        $this->workPhone = $this->getRawWorkPhone();
                    }
                } else {
                    $this->workPhone = $this->getRawWorkPhone();
                }
            }
        }
        return $this->workPhone;
    }
public function getWorkPhone ( ) { if ( ! isset ( $ this -> workPhone ) ) { $ wp = trim ( $ this -> getRawWorkPhone ( ) ) ; if ( empty ( $ wp ) ) { $ this -> workPhone = null ; } else { if ( preg_match ( '/^\+?[-\d\s()]+/' , $ wp , $ matches ) ) { $ wp = $ matches [ 0 ] ; $ wp = trim ( str_replace ( [ '(' , ')' ] , '' , $ wp ) ) ; if ( strlen ( str_replace ( ' ' , '' , $ wp ) ) === 4 ) { $ wp = self :: phonePrefixForExt ( $ wp ) . $ wp ; } if ( $ wp [ 0 ] !== '0' && $ wp [ 0 ] !== '+' ) { $ wp = '08' . $ wp ; } $ phoneUtil = \ libphonenumber \ PhoneNumberUtil :: getInstance ( ) ; try { $ this -> workPhone = $ phoneUtil -> parse ( $ wp , 'SE' ) ; } catch ( \ libphonenumber \ NumberParseException $ e ) { $ this -> workPhone = $ this -> getRawWorkPhone ( ) ; } } else { $ this -> workPhone = $ this -> getRawWorkPhone ( ) ; } } } return $ this -> workPhone ; }
Get work phone number of this employee. Try to parse it to a
PhoneNumber, otherwise return the raw string.

@return PhoneNumber|string|null The work phone number, or null if missing.
Get work phone number of this employee . Try to parse it to a PhoneNumber otherwise return the raw string .