public static function byId(
        Client $client,
        int $id
    ): self {
        $posts = self::search($client, ['id:' . $id], 1, 1);

        if (count($posts) === 0) {
            throw new PostNotFoundException(sprintf(
                'Post with ID %d not found',
                $id
            ));
        }

        return $posts[0];
    }
public static function byId(
        Client $client,
        int $id
    ): self {
        $posts = self::search($client, ['id:' . $id], 1, 1);

        if (count($posts) === 0) {
            throw new PostNotFoundException(sprintf(
                'Post with ID %d not found',
                $id
            ));
        }

        return $posts[0];
    }
public static function byId ( Client $ client , int $ id ) : self { $ posts = self :: search ( $ client , [ 'id:' . $ id ] , 1 , 1 ) ; if ( count ( $ posts ) === 0 ) { throw new PostNotFoundException ( sprintf ( 'Post with ID %d not found' , $ id ) ) ; } return $ posts [ 0 ] ; }
Get certain post by its ID or throw exception if nothing found.

@param Client $client
@param int    $id

@throws PostNotFoundException if post not found

@return Post
Get certain post by its ID or throw exception if nothing found .