src/ValueObject/Size.php
public static function fromString($size, $unit = 'px', $separator = ' x ')
    {
        if (is_string($size)) {
            $matches = [];
            $pattern = Regex::getSizePattern($separator);

            if ((bool)preg_match($pattern, $size, $matches)) {
                $width = (int)$matches[1];
                $height = (int)$matches[2];
                $sizeObject = new self($width, $height, $unit);

                return $sizeObject->setSeparator($separator);
            }
        }

        return null;
    }
public static function fromString($size, $unit = 'px', $separator = ' x ')
    {
        if (is_string($size)) {
            $matches = [];
            $pattern = Regex::getSizePattern($separator);

            if ((bool)preg_match($pattern, $size, $matches)) {
                $width = (int)$matches[1];
                $height = (int)$matches[2];
                $sizeObject = new self($width, $height, $unit);

                return $sizeObject->setSeparator($separator);
            }
        }

        return null;
    }
public static function fromString ( $ size , $ unit = 'px' , $ separator = ' x ' ) { if ( is_string ( $ size ) ) { $ matches = [ ] ; $ pattern = Regex :: getSizePattern ( $ separator ) ; if ( ( bool ) preg_match ( $ pattern , $ size , $ matches ) ) { $ width = ( int ) $ matches [ 1 ] ; $ height = ( int ) $ matches [ 2 ] ; $ sizeObject = new self ( $ width , $ height , $ unit ) ; return $ sizeObject -> setSeparator ( $ separator ) ; } } return null ; }
Creates new instance from given string

@param string $size      The size represented as string (width and height separated by given separator)
@param string $unit      (optional) Unit used when width or height should be returned with unit. Default: "px".
@param string $separator (optional) Separator used to split width and height. Default: " x ".
@return null|Size
Creates new instance from given string