public function create(WP_Post $attachment, Size $size): Source
    {
        if (!wp_attachment_is_image($attachment)) {
            throw new InvalidArgumentException('Attachment must be an image.');
        }

        $imageSource = (array)wp_get_attachment_image_src(
            $attachment->ID,
            [$size->width(), $size->height()]
        );
        $imageSource = array_filter($imageSource);

        if (!$imageSource) {
            throw new DomainException(
                sprintf('Image with ID: %d, no longer exists', $attachment->ID)
            );
        }

        return new Source(...$imageSource);
    }
public function create(WP_Post $attachment, Size $size): Source
    {
        if (!wp_attachment_is_image($attachment)) {
            throw new InvalidArgumentException('Attachment must be an image.');
        }

        $imageSource = (array)wp_get_attachment_image_src(
            $attachment->ID,
            [$size->width(), $size->height()]
        );
        $imageSource = array_filter($imageSource);

        if (!$imageSource) {
            throw new DomainException(
                sprintf('Image with ID: %d, no longer exists', $attachment->ID)
            );
        }

        return new Source(...$imageSource);
    }
public function create ( WP_Post $ attachment , Size $ size ) : Source { if ( ! wp_attachment_is_image ( $ attachment ) ) { throw new InvalidArgumentException ( 'Attachment must be an image.' ) ; } $ imageSource = ( array ) wp_get_attachment_image_src ( $ attachment -> ID , [ $ size -> width ( ) , $ size -> height ( ) ] ) ; $ imageSource = array_filter ( $ imageSource ) ; if ( ! $ imageSource ) { throw new DomainException ( sprintf ( 'Image with ID: %d, no longer exists' , $ attachment -> ID ) ) ; } return new Source ( ... $ imageSource ) ; }
Create an Instance of Source by the Given Attachment Post and Size

@param WP_Post $attachment
@param Size $size
@return Source
@throws InvalidArgumentException
@throws DomainException
@throws LengthException
Create an Instance of Source by the Given Attachment Post and Size