Code Duplication    Length = 60-61 lines in 2 locations

src/cli/Database/Base/Connection.php 1 location

@@ 984-1043 (lines=60) @@
981
     *
982
     * @return array an associative array containing the field names (as keys) and field values
983
     */
984
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
985
    {
986
987
        if (isset($alreadyDumpedObjects['Connection'][$this->hashCode()])) {
988
            return '*RECURSION*';
989
        }
990
        $alreadyDumpedObjects['Connection'][$this->hashCode()] = true;
991
        $keys = ConnectionTableMap::getFieldNames($keyType);
992
        $result = array(
993
            $keys[0] => $this->getId(),
994
            $keys[1] => $this->getInstanceName(),
995
            $keys[2] => $this->getUserId(),
996
            $keys[3] => $this->getPeer(),
997
            $keys[4] => $this->getStarted(),
998
            $keys[5] => $this->getType(),
999
        );
1000
        if ($result[$keys[4]] instanceof \DateTime) {
1001
            $result[$keys[4]] = $result[$keys[4]]->format('c');
1002
        }
1003
1004
        $virtualColumns = $this->virtualColumns;
1005
        foreach ($virtualColumns as $key => $virtualColumn) {
1006
            $result[$key] = $virtualColumn;
1007
        }
1008
1009
        if ($includeForeignObjects) {
1010
            if (null !== $this->aInstance) {
1011
1012
                switch ($keyType) {
1013
                    case TableMap::TYPE_CAMELNAME:
1014
                        $key = 'instance';
1015
                        break;
1016
                    case TableMap::TYPE_FIELDNAME:
1017
                        $key = 'instance';
1018
                        break;
1019
                    default:
1020
                        $key = 'Instance';
1021
                }
1022
1023
                $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1024
            }
1025
            if (null !== $this->aUser) {
1026
1027
                switch ($keyType) {
1028
                    case TableMap::TYPE_CAMELNAME:
1029
                        $key = 'user';
1030
                        break;
1031
                    case TableMap::TYPE_FIELDNAME:
1032
                        $key = 'user';
1033
                        break;
1034
                    default:
1035
                        $key = 'User';
1036
                }
1037
1038
                $result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1039
            }
1040
        }
1041
1042
        return $result;
1043
    }
1044
1045
    /**
1046
     * Sets a field from the object by name passed in as a string.

src/cli/Database/Base/Input.php 1 location

@@ 1037-1097 (lines=61) @@
1034
     *
1035
     * @return array an associative array containing the field names (as keys) and field values
1036
     */
1037
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1038
    {
1039
1040
        if (isset($alreadyDumpedObjects['Input'][$this->hashCode()])) {
1041
            return '*RECURSION*';
1042
        }
1043
        $alreadyDumpedObjects['Input'][$this->hashCode()] = true;
1044
        $keys = InputTableMap::getFieldNames($keyType);
1045
        $result = array(
1046
            $keys[0] => $this->getUuid(),
1047
            $keys[1] => $this->getInstanceName(),
1048
            $keys[2] => $this->getStarted(),
1049
            $keys[3] => $this->getInput(),
1050
            $keys[4] => $this->getNetwork(),
1051
            $keys[5] => $this->getMux(),
1052
            $keys[6] => $this->getWeight(),
1053
        );
1054
        if ($result[$keys[2]] instanceof \DateTime) {
1055
            $result[$keys[2]] = $result[$keys[2]]->format('c');
1056
        }
1057
1058
        $virtualColumns = $this->virtualColumns;
1059
        foreach ($virtualColumns as $key => $virtualColumn) {
1060
            $result[$key] = $virtualColumn;
1061
        }
1062
1063
        if ($includeForeignObjects) {
1064
            if (null !== $this->aInstance) {
1065
1066
                switch ($keyType) {
1067
                    case TableMap::TYPE_CAMELNAME:
1068
                        $key = 'instance';
1069
                        break;
1070
                    case TableMap::TYPE_FIELDNAME:
1071
                        $key = 'instance';
1072
                        break;
1073
                    default:
1074
                        $key = 'Instance';
1075
                }
1076
1077
                $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1078
            }
1079
            if (null !== $this->collSubscriptions) {
1080
1081
                switch ($keyType) {
1082
                    case TableMap::TYPE_CAMELNAME:
1083
                        $key = 'subscriptions';
1084
                        break;
1085
                    case TableMap::TYPE_FIELDNAME:
1086
                        $key = 'subscriptions';
1087
                        break;
1088
                    default:
1089
                        $key = 'Subscriptions';
1090
                }
1091
1092
                $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1093
            }
1094
        }
1095
1096
        return $result;
1097
    }
1098
1099
    /**
1100
     * Sets a field from the object by name passed in as a string.