Code Duplication    Length = 20-20 lines in 2 locations

src/Plugin/Deriver/Fields/ViewDeriver.php 1 location

@@ 174-193 (lines=20) @@
171
      return $types;
172
    }
173
174
    foreach ($arguments as $argument) {
175
      // Depending on whether bundles are known, we expose the view field
176
      // either on the interface (e.g. Node) or on the type (e.g. NodePage)
177
      // level. Here we specify types managed by other graphql_* modules,
178
      // yet we don't define these modules as dependencies. If types are not
179
      // in the schema, the resulting GraphQL field will be attached to
180
      // nowhere, so it won't go into the schema.
181
      if (empty($argument['bundles']) && empty($argument['entity_type'])) {
182
        continue;
183
      }
184
185
      if (empty($argument['bundles'])) {
186
        $types = array_merge($types, [StringHelper::camelCase($argument['entity_type'])]);
187
      }
188
      else {
189
        $types = array_merge($types, array_map(function ($bundle) use ($argument) {
190
          return StringHelper::camelCase($argument['entity_type'], $bundle);
191
        }, array_keys($argument['bundles'])));
192
      }
193
    }
194
195
    return $types;
196
  }

src/ViewDeriverHelperTrait.php 1 location

@@ 126-145 (lines=20) @@
123
      return $types;
124
    }
125
126
    foreach ($arguments as $argument) {
127
      // Depending on whether bundles are known, we expose the view field
128
      // either on the interface (e.g. Node) or on the type (e.g. NodePage)
129
      // level. Here we specify types managed by other graphql_* modules,
130
      // yet we don't define these modules as dependencies. If types are not
131
      // in the schema, the resulting GraphQL field will be attached to
132
      // nowhere, so it won't go into the schema.
133
      if (empty($argument['bundles']) && empty($argument['entity_type'])) {
134
        continue;
135
      }
136
137
      if (empty($argument['bundles'])) {
138
        $types = array_merge($types, [StringHelper::camelCase($argument['entity_type'])]);
139
      }
140
      else {
141
        $types = array_merge($types, array_map(function ($bundle) use ($argument) {
142
          return StringHelper::camelCase($argument['entity_type'], $bundle);
143
        }, array_keys($argument['bundles'])));
144
      }
145
    }
146
147
    return $types;
148
  }