summaryrefslogtreecommitdiff
path: root/vendor/opentracing/opentracing/src/OpenTracing/InvalidSpanOptionException.php
blob: f9b8003ffe8c111503b1b834f786d4a6facde02c (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php

declare(strict_types=1);

namespace OpenTracing;

use InvalidArgumentException;

/**
 * Thrown when passing an invalid option on Span creation
 */
final class InvalidSpanOptionException extends InvalidArgumentException
{
    /**
     * @return InvalidSpanOptionException
     */
    public static function forIncludingBothChildOfAndReferences(): InvalidSpanOptionException
    {
        return new self('Either "childOf" or "references" options are accepted but not both.');
    }

    /**
     * @param mixed $reference
     * @return InvalidSpanOptionException
     */
    public static function forInvalidReference($reference): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid reference. Expected OpenTracing\Reference, got %s.',
            is_object($reference) ? get_class($reference) : gettype($reference)
        ));
    }

    /**
     * @return InvalidSpanOptionException
     */
    public static function forInvalidStartTime(): InvalidSpanOptionException
    {
        return new self('Invalid start_time option. Expected int or float got string.');
    }

    /**
     * @param mixed $childOfOption
     * @return InvalidSpanOptionException
     */
    public static function forInvalidChildOf($childOfOption): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid child_of option. Expected Span or SpanContext, got %s',
            is_object($childOfOption) ? get_class($childOfOption) : gettype($childOfOption)
        ));
    }

    /**
     * @param string $key
     * @return InvalidSpanOptionException
     */
    public static function forUnknownOption(string $key): InvalidSpanOptionException
    {
        return new self(sprintf('Invalid option %s.', $key));
    }

    /**
     * @param mixed $tag
     * @return InvalidSpanOptionException
     */
    public static function forInvalidTag($tag): InvalidSpanOptionException
    {
        return new self(sprintf('Invalid tag. Expected string, got %s', gettype($tag)));
    }

    /**
     * @param mixed $tagValue
     * @return InvalidSpanOptionException
     */
    public static function forInvalidTagValue($tagValue): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid tag value. Expected scalar or object with __toString method, got %s',
            is_object($tagValue) ? get_class($tagValue) : gettype($tagValue)
        ));
    }

    /**
     * @param mixed $value
     * @return InvalidSpanOptionException
     */
    public static function forInvalidTags($value): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid tags value. Expected a associative array of tags, got %s',
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }

    /**
     * @param mixed $value
     * @return InvalidSpanOptionException
     */
    public static function forInvalidReferenceSet($value): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid references set. Expected Reference or Reference[], got %s',
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }

    /**
     * @param mixed $value
     * @return InvalidSpanOptionException
     */
    public static function forFinishSpanOnClose($value): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid type for finish_span_on_close. Expected bool, got %s',
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }

    /**
     * @param mixed $value
     * @return InvalidSpanOptionException
     */
    public static function forIgnoreActiveSpan($value): InvalidSpanOptionException
    {
        return new self(sprintf(
            'Invalid type for ignore_active_span. Expected bool, got %s',
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }
}