-
Notifications
You must be signed in to change notification settings - Fork 11
/
ArticleCommand.php
72 lines (61 loc) · 1.59 KB
/
ArticleCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/*
* This file is part of the NNTP library.
*
* (c) Robin van der Vleuten <robin@webstronauts.co>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Rvdv\Nntp\Command;
use Rvdv\Nntp\Exception\RuntimeException;
use Rvdv\Nntp\Response\MultiLineResponse;
use Rvdv\Nntp\Response\Response;
/**
* BodyCommand.
*
* @author thebandit
*/
class ArticleCommand extends Command
{
/**
* @var string
*/
private $article;
/**
* Constructor.
*
* @param string $article the number or msg-id of the article
*/
public function __construct($article)
{
$this->article = $article;
parent::__construct(true);
}
/**
* {@inheritdoc}
*/
public function __invoke()
{
return sprintf('ARTICLE %s', $this->article);
}
/**
* @return string
*/
public function onArticleFollows(MultiLineResponse $response)
{
return implode("\r\n", $response->getLines());
}
public function onNoNewsGroupCurrentSelected(Response $response)
{
throw new RuntimeException('A group must be selected first before getting an article.', $response->getStatusCode());
}
public function onNoSuchArticleNumber(Response $response)
{
throw new RuntimeException('No article with that number.', $response->getStatusCode());
}
public function onNoSuchArticleId(Response $response)
{
throw new RuntimeException('No article with that message-id.', $response->getStatusCode());
}
}