Code Duplication    Length = 17-18 lines in 2 locations

src/Formatters/CsvFormatter.php 1 location

@@ 12-29 (lines=18) @@
9
10
class CsvFormatter implements FormatterInterface, ValidationInterface
11
{
12
    public function validate($structuredData)
13
    {
14
        // If the provided data was of class RowsOfFields
15
        // or AssociativeList, it will be converted into
16
        // a TableTransformation object.
17
        if (!is_array($structuredData) && (!$structuredData instanceof TableTransformation)) {
18
            throw new IncompatibleDataException(
19
                $this,
20
                $structuredData,
21
                [
22
                    new \ReflectionClass('\Consolidation\OutputFormatters\StructuredData\RowsOfFields'),
23
                    new \ReflectionClass('\Consolidation\OutputFormatters\StructuredData\AssociativeList'),
24
                    [],
25
                ]
26
            );
27
        }
28
        return $structuredData;
29
    }
30
31
    /**
32
     * @inheritdoc

src/Formatters/TableFormatter.php 1 location

@@ 36-52 (lines=17) @@
33
        }
34
    }
35
36
    public function validate($structuredData)
37
    {
38
        // If the provided data was of class RowsOfFields
39
        // or AssociativeList, it will be converted into
40
        // a TableTransformation object by the restructure call.
41
        if (!$structuredData instanceof TableDataInterface) {
42
            throw new IncompatibleDataException(
43
                $this,
44
                $structuredData,
45
                [
46
                    new \ReflectionClass('\Consolidation\OutputFormatters\StructuredData\RowsOfFields'),
47
                    new \ReflectionClass('\Consolidation\OutputFormatters\StructuredData\AssociativeList'),
48
                ]
49
            );
50
        }
51
        return $structuredData;
52
    }
53
54
    /**
55
     * @inheritdoc