Code Duplication    Length = 29-29 lines in 2 locations

src/Tag/KeyTag.php 1 location

@@ 145-173 (lines=29) @@
142
        return $this->keyFormatVersions;
143
    }
144
145
    public function dump()
146
    {
147
        $attrs = [];
148
        foreach (get_object_vars($this) as $prop => $value) {
149
            if (empty($value)) {
150
                continue;
151
            }
152
153
            if ('uri' === $prop || 'keyFormat' === $prop) {
154
                $attrs[] = sprintf('%s="%s"', strtoupper($prop), $value);
155
156
                continue;
157
            }
158
159
            if ('keyFormatVersions' === $prop) {
160
                $attrs[] = sprintf('KEYFORMATVERSIONS="%s"', implode('/', $value));
161
162
                continue;
163
            }
164
165
            $attrs[] = sprintf('%s=%s', strtoupper($prop), $value);
166
        }
167
168
        if (empty($attrs)) {
169
            return;
170
        }
171
172
        return sprintf('%s:%s', self::TAG_IDENTIFIER, implode(',', $attrs));
173
    }
174
175
    protected function read($line)
176
    {

src/Tag/StreamInfTag.php 1 location

@@ 120-148 (lines=29) @@
117
        return $this->codecs;
118
    }
119
120
    public function dump()
121
    {
122
        $attrs = [];
123
        foreach (get_object_vars($this) as $prop => $value) {
124
            if (empty($value)) {
125
                continue;
126
            }
127
128
            if ('codecs' === $prop) {
129
                $attrs[] = sprintf('%s="%s"', strtoupper($prop), implode(',', $value));
130
131
                continue;
132
            }
133
134
            if ('programId' === $prop) {
135
                $attrs[] = sprintf('%s=%s', 'PROGRAM-ID', $value);
136
137
                continue;
138
            }
139
140
            $attrs[] = sprintf('%s=%s', strtoupper($prop), $value);
141
        }
142
143
        if (empty($attrs)) {
144
            return;
145
        }
146
147
        return sprintf('%s:%s', self::TAG_IDENTIFIER, implode(',', $attrs));
148
    }
149
150
    protected function read($line)
151
    {