Test Failed
Pull Request — master (#12)
by wujunze
03:09
created

InvalidRecordInSet   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 38
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A valueIsNotString() 0 3 1
A missingValue() 0 3 1
A missingTopic() 0 3 1
A topicIsNotString() 0 3 1
A nonExististingTopic() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Seasx\SeasLogger\Kafka;
5
6
use Exception;
7
use function sprintf;
8
9
/**
10
 * Class InvalidRecordInSet
11
 * @package Seasx\SeasLogger\Kafka
12
 */
13
final class InvalidRecordInSet extends Exception
14
{
15
    /**
16
     * @return InvalidRecordInSet
17
     */
18
    public static function missingTopic(): self
19
    {
20
        return new self('You have to set "topic" to your message.');
21
    }
22
23
    /**
24
     * @param string $topic
25
     * @return InvalidRecordInSet
26
     */
27
    public static function nonExististingTopic(string $topic): self
28
    {
29
        return new self(sprintf('Requested topic "%s" does not exist. Did you forget to create it?', $topic));
30
    }
31
32
    /**
33
     * @return InvalidRecordInSet
34
     */
35
    public static function topicIsNotString(): self
36
    {
37
        return new self('Topic must be string.');
38
    }
39
40
    public static function missingValue(): self
41
    {
42
        return new self('You have to set "value" to your message.');
43
    }
44
45
    /**
46
     * @return InvalidRecordInSet
47
     */
48
    public static function valueIsNotString(): self
49
    {
50
        return new self('Value must be string.');
51
    }
52
}
53