Code Duplication    Length = 12-12 lines in 5 locations

src/Rosetta.php 5 locations

@@ 21-32 (lines=12) @@
18
     *
19
     * @return Connector
20
     */
21
    public static function connector($class, $config = [])
22
    {
23
        if (!str_contains($class, '\\')) {
24
            $class = '\\Ghc\\Rosetta\\Connectors\\'.studly_case($class);
25
        }
26
27
        if (!class_exists($class)) {
28
            throw ManagerException::undefinedConnector($class);
29
        }
30
31
        return new $class($config);
32
    }
33
34
    /**
35
     * @param Connector  $connector
@@ 57-68 (lines=12) @@
54
     *
55
     * @return Message
56
     */
57
    public static function message($class, $data = null, $config = [])
58
    {
59
        if (!str_contains($class, '\\')) {
60
            $class = '\\Ghc\\Rosetta\\Messages\\'.studly_case($class);
61
        }
62
63
        if (!class_exists($class)) {
64
            throw ManagerException::undefinedMessage($class);
65
        }
66
67
        return new $class($data, $config);
68
    }
69
70
    /**
71
     * @param string $class
@@ 78-89 (lines=12) @@
75
     *
76
     * @return Message
77
     */
78
    public static function transformer($class, $config = [])
79
    {
80
        if (!str_contains($class, '\\')) {
81
            $class = '\\Ghc\\Rosetta\\Transformers\\'.studly_case($class);
82
        }
83
84
        if (!class_exists($class)) {
85
            throw ManagerException::undefinedTransformer($class);
86
        }
87
88
        return new $class($config);
89
    }
90
91
    /**
92
     * @param array|mixed               $data
@@ 120-131 (lines=12) @@
117
     *
118
     * @return
119
     */
120
    public static function pipe($class)
121
    {
122
        if (!str_contains($class, '\\')) {
123
            $class = '\\Ghc\\Rosetta\\Pipes\\'.studly_case($class);
124
        }
125
126
        if (!class_exists($class)) {
127
            throw ManagerException::undefinedPipe($class);
128
        }
129
130
        return new $class();
131
    }
132
133
    /**
134
     * @param string     $class
@@ 142-153 (lines=12) @@
139
     *
140
     * @return
141
     */
142
    public static function matcher($class, $data = null, $config = [])
143
    {
144
        if (!str_contains($class, '\\')) {
145
            $class = '\\Ghc\\Rosetta\\Matchers\\'.studly_case($class);
146
        }
147
148
        if (!class_exists($class)) {
149
            throw ManagerException::undefinedMatcher($class);
150
        }
151
152
        return new $class($data, $config);
153
    }
154
155
    /**
156
     * @param array $config