Code Duplication    Length = 5-7 lines in 2 locations

src/MessageTrait.php 2 locations

@@ 77-81 (lines=5) @@
74
75
    public function withHeader($header, $value): self
76
    {
77
        if (!is_array($value)) {
78
            $value = [$value];
79
        } elseif (empty($value)) {
80
            throw new \InvalidArgumentException('Header values must be non-empty strings');
81
        }
82
83
        if (!is_string($header) || empty($header)) {
84
            throw new \InvalidArgumentException('Header name must be non-empty strings');
@@ 108-114 (lines=7) @@
105
106
    public function withAddedHeader($header, $value): self
107
    {
108
        if (!is_array($value)) {
109
            $value = [$value];
110
        } elseif (!empty($value)) {
111
            $value = array_values($value);
112
        } else {
113
            throw new \InvalidArgumentException('Header values must be non-empty strings');
114
        }
115
116
        if (!is_string($header) || empty($header)) {
117
            throw new \InvalidArgumentException('Header name must be non-empty strings');