public static function fromFocalLength($focalLength)
    {
        if (!is_string($focalLength)) {
            throw new InvalidArgumentException('focalLength must be a string');
        }

        if (!preg_match('#^f/([0-9]*\.[0-9]+|[0-9]*)$#', $focalLength, $matches)) {
            throw new RuntimeException('Given focalLength is not in a valid format. Need: "f/<number>"');
        }

        $fNumber = $matches[1];

        if (($filtered = filter_var($fNumber, FILTER_VALIDATE_INT)) !== false) {
            $fNumber = $filtered;
        } else {
            $fNumber = (float) $fNumber;
        }

        return new self($fNumber);
    }
public static function fromFocalLength($focalLength)
    {
        if (!is_string($focalLength)) {
            throw new InvalidArgumentException('focalLength must be a string');
        }

        if (!preg_match('#^f/([0-9]*\.[0-9]+|[0-9]*)$#', $focalLength, $matches)) {
            throw new RuntimeException('Given focalLength is not in a valid format. Need: "f/<number>"');
        }

        $fNumber = $matches[1];

        if (($filtered = filter_var($fNumber, FILTER_VALIDATE_INT)) !== false) {
            $fNumber = $filtered;
        } else {
            $fNumber = (float) $fNumber;
        }

        return new self($fNumber);
    }
public static function fromFocalLength ( $ focalLength ) { if ( ! is_string ( $ focalLength ) ) { throw new InvalidArgumentException ( 'focalLength must be a string' ) ; } if ( ! preg_match ( '#^f/([0-9]*\.[0-9]+|[0-9]*)$#' , $ focalLength , $ matches ) ) { throw new RuntimeException ( 'Given focalLength is not in a valid format. Need: "f/<number>"' ) ; } $ fNumber = $ matches [ 1 ] ; if ( ( $ filtered = filter_var ( $ fNumber , FILTER_VALIDATE_INT ) ) !== false ) { $ fNumber = $ filtered ; } else { $ fNumber = ( float ) $ fNumber ; } return new self ( $ fNumber ) ; }
Creates new instance from given Focal Length format

Format:
f/<f-number>

@param string $focalLength

@throws \InvalidArgumentException If focalLength is not a string

@return Aperture
Creates new instance from given Focal Length format