Code Duplication    Length = 26-26 lines in 2 locations

src/Plugins/PluginFactory.php 1 location

@@ 98-123 (lines=26) @@
95
        }
96
97
        // query whether or not we've a plugin instance that implements the exportable plugin interface
98
        if ($pluginInstance instanceof ExportablePluginInterface) {
99
            // load the export adapter instance from the DI container and set it on the plugin instance
100
            $exportAdapter = $this->container->get($pluginConfiguration->getExportAdapter()->getId());
101
102
            // query whether or not we've found a factory or the instance itself
103
            if ($exportAdapter instanceof ExportAdapterInterface) {
104
                // inject the export adapter into the subject
105
                $pluginInstance->setExportAdapter($exportAdapter);
106
                // log a warning, that this is deprecated
107
                $this->getSystemLogger()->warning(
108
                    sprintf(
109
                        'Direct injection of export adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
110
                        $pluginConfiguration->getExportAdapter()->getId()
111
                    )
112
                );
113
            } elseif ($exportAdapter instanceof ExportAdapterFactoryInterface) {
114
                $pluginInstance->setExportAdapter($exportAdapter->createExportAdapter($pluginConfiguration));
115
            } else {
116
                throw new \Exception(
117
                    sprintf(
118
                        'Expected either an instance of ExportAdapterInterface or ExportAdapterFactoryInterface for DI ID "%s"',
119
                        $pluginConfiguration->getExportAdapter()->getId()
120
                    )
121
                );
122
            }
123
        }
124
125
        // return the plugin instance
126
        return $pluginInstance;

src/Subjects/SubjectFactory.php 1 location

@@ 133-158 (lines=26) @@
130
        }
131
132
        // query whether or not we've a subject instance that implements the exportable subject interface
133
        if ($subjectInstance instanceof ExportableSubjectInterface) {
134
            // load the export adapter instance from the DI container and set it on the subject instance
135
            $exportAdapter = $this->container->get($subjectConfiguration->getExportAdapter()->getId());
136
137
            // query whether or not we've found a factory or the instance itself
138
            if ($exportAdapter instanceof ExportAdapterInterface) {
139
                // inject the export adapter into the subject
140
                $subjectInstance->setExportAdapter($exportAdapter);
141
                // log a warning, that this is deprecated
142
                $this->getSystemLogger()->warning(
143
                    sprintf(
144
                        'Direct injection of export adapter with DI ID "%s" is deprecated since version 3.0.0, please use factory instead',
145
                        $subjectConfiguration->getExportAdapter()->getId()
146
                    )
147
                );
148
            } elseif ($exportAdapter instanceof ExportAdapterFactoryInterface) {
149
                $subjectInstance->setExportAdapter($exportAdapter->createExportAdapter($subjectConfiguration));
150
            } else {
151
                throw new \Exception(
152
                    sprintf(
153
                        'Expected either an instance of ExportAdapterInterface or ExportAdapterFactoryInterface for DI ID "%s"',
154
                        $subjectConfiguration->getExportAdapter()->getId()
155
                    )
156
                );
157
            }
158
        }
159
160
        // load te number converter instance from the DI container and set it on the subject instance
161
        if ($subjectInstance instanceof NumberConverterSubjectInterface) {