Code Duplication    Length = 16-17 lines in 2 locations

src/Serializers/EcSerializer.php 1 location

@@ 31-46 (lines=16) @@
28
  /**
29
   * Removes linked info.
30
   */
31
  protected function attributes($ec_term) {
32
    self::$potentialDataTables = \Drupal\esdportal_api\EcDataUtils::getDataTablesWithProgramIds();
33
    self::$potentialDataTableNames = \Drupal\esdportal_api\EcDataUtils::extractDataTableNames(self::$potentialDataTables);
34
35
    // These turn into linkages:
36
    unset($ec_term->ec_profile);
37
    unset($ec_term->ec_profile_id);
38
    unset($ec_term->most_recent_ec_state_rating);
39
    unset($ec_term->most_recent_ec_state_rating_id);
40
41
    foreach (self::$potentialDataTableNames as $name) {
42
      unset($ec_term->{$name});
43
    }
44
45
    return $ec_term;
46
  }
47
48
  /**
49
   * Returns the id.

src/Serializers/SchoolSerializer.php 1 location

@@ 51-67 (lines=17) @@
48
  /**
49
   * Unsets any included data.
50
   */
51
  protected function attributes($school_term) {
52
    self::$potentialDataTables = \Drupal\esdportal_api\EcDataUtils::getDataTablesWithBcodes();
53
    self::$potentialDataTableNames = \Drupal\esdportal_api\EcDataUtils::extractDataTableNames(self::$potentialDataTables);
54
55
    // These turn into linkages:
56
    unset($school_term->school_profile);
57
    unset($school_term->school_profile_id);
58
59
    // These fields are private:
60
    unset($school_term->field_files);
61
62
    foreach (self::$potentialDataTableNames as $name) {
63
      unset($school_term->{$name});
64
    }
65
66
    return $school_term;
67
  }
68
69
  /**
70
   * Provides taxonomy term id as id.