Code Duplication    Length = 13-18 lines in 4 locations

eZ/Publish/Core/Repository/ProxyFactory/ProxyDomainMapper.php 4 locations

@@ 78-95 (lines=18) @@
75
        return $this->factory->createProxy(ContentInfo::class, $initializer);
76
    }
77
78
    public function createContentTypeProxy(
79
        int $contentTypeId,
80
        array $prioritizedLanguages = Language::ALL
81
    ): ContentType {
82
        $initializer = function (
83
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
84
        ) use ($contentTypeId, $prioritizedLanguages): bool {
85
            $initializer = null;
86
            $wrappedObject = $this->repository->getContentTypeService()->loadContentType(
87
                $contentTypeId,
88
                $prioritizedLanguages
89
            );
90
91
            return true;
92
        };
93
94
        return $this->factory->createProxy(ContentType::class, $initializer);
95
    }
96
97
    public function createContentTypeGroupProxy(
98
        int $contentTypeGroupId,
@@ 97-114 (lines=18) @@
94
        return $this->factory->createProxy(ContentType::class, $initializer);
95
    }
96
97
    public function createContentTypeGroupProxy(
98
        int $contentTypeGroupId,
99
        array $prioritizedLanguages = Language::ALL
100
    ): ContentTypeGroup {
101
        $initializer = function (
102
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
103
        ) use ($contentTypeGroupId, $prioritizedLanguages): bool {
104
            $initializer = null;
105
            $wrappedObject = $this->repository->getContentTypeService()->loadContentTypeGroup(
106
                $contentTypeGroupId,
107
                $prioritizedLanguages
108
            );
109
110
            return true;
111
        };
112
113
        return $this->factory->createProxy(ContentTypeGroup::class, $initializer);
114
    }
115
116
    public function createContentTypeGroupProxyList(
117
        array $contentTypeGroupIds,
@@ 142-159 (lines=18) @@
139
        return $this->factory->createProxy(Language::class, $initializer);
140
    }
141
142
    public function createLocationProxy(
143
        int $locationId,
144
        array $prioritizedLanguages = Language::ALL
145
    ): Location {
146
        $initializer = function (
147
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
148
        ) use ($locationId, $prioritizedLanguages): bool {
149
            $initializer = null;
150
            $wrappedObject = $this->repository->getLocationService()->loadLocation(
151
                $locationId,
152
                $prioritizedLanguages
153
            );
154
155
            return true;
156
        };
157
158
        return $this->factory->createProxy(Location::class, $initializer);
159
    }
160
161
    public function createSectionProxy(int $sectionId): Section
162
    {
@@ 175-187 (lines=13) @@
172
        return $this->factory->createProxy(Section::class, $initializer);
173
    }
174
175
    public function createUserProxy(int $userId, array $prioritizedLanguages = Language::ALL): User
176
    {
177
        $initializer = function (
178
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
179
        ) use ($userId, $prioritizedLanguages): bool {
180
            $initializer = null;
181
            $wrappedObject = $this->repository->getUserService()->loadUser($userId, $prioritizedLanguages);
182
183
            return true;
184
        };
185
186
        return $this->factory->createProxy(User::class, $initializer);
187
    }
188
}
189