Code Duplication    Length = 13-18 lines in 4 locations

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

@@ 77-94 (lines=18) @@
74
        return $this->proxyGenerator->createProxy(ContentInfo::class, $initializer);
75
    }
76
77
    public function createContentTypeProxy(
78
        int $contentTypeId,
79
        array $prioritizedLanguages = Language::ALL
80
    ): ContentType {
81
        $initializer = function (
82
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
83
        ) use ($contentTypeId, $prioritizedLanguages): bool {
84
            $initializer = null;
85
            $wrappedObject = $this->repository->getContentTypeService()->loadContentType(
86
                $contentTypeId,
87
                $prioritizedLanguages
88
            );
89
90
            return true;
91
        };
92
93
        return $this->proxyGenerator->createProxy(ContentType::class, $initializer);
94
    }
95
96
    public function createContentTypeGroupProxy(
97
        int $contentTypeGroupId,
@@ 96-113 (lines=18) @@
93
        return $this->proxyGenerator->createProxy(ContentType::class, $initializer);
94
    }
95
96
    public function createContentTypeGroupProxy(
97
        int $contentTypeGroupId,
98
        array $prioritizedLanguages = Language::ALL
99
    ): ContentTypeGroup {
100
        $initializer = function (
101
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
102
        ) use ($contentTypeGroupId, $prioritizedLanguages): bool {
103
            $initializer = null;
104
            $wrappedObject = $this->repository->getContentTypeService()->loadContentTypeGroup(
105
                $contentTypeGroupId,
106
                $prioritizedLanguages
107
            );
108
109
            return true;
110
        };
111
112
        return $this->proxyGenerator->createProxy(ContentTypeGroup::class, $initializer);
113
    }
114
115
    public function createContentTypeGroupProxyList(
116
        array $contentTypeGroupIds,
@@ 151-168 (lines=18) @@
148
        return $languages;
149
    }
150
151
    public function createLocationProxy(
152
        int $locationId,
153
        array $prioritizedLanguages = Language::ALL
154
    ): Location {
155
        $initializer = function (
156
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
157
        ) use ($locationId, $prioritizedLanguages): bool {
158
            $initializer = null;
159
            $wrappedObject = $this->repository->getLocationService()->loadLocation(
160
                $locationId,
161
                $prioritizedLanguages
162
            );
163
164
            return true;
165
        };
166
167
        return $this->proxyGenerator->createProxy(Location::class, $initializer);
168
    }
169
170
    public function createSectionProxy(int $sectionId): Section
171
    {
@@ 184-196 (lines=13) @@
181
        return $this->proxyGenerator->createProxy(Section::class, $initializer);
182
    }
183
184
    public function createUserProxy(int $userId, array $prioritizedLanguages = Language::ALL): User
185
    {
186
        $initializer = function (
187
            &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer
188
        ) use ($userId, $prioritizedLanguages): bool {
189
            $initializer = null;
190
            $wrappedObject = $this->repository->getUserService()->loadUser($userId, $prioritizedLanguages);
191
192
            return true;
193
        };
194
195
        return $this->proxyGenerator->createProxy(User::class, $initializer);
196
    }
197
}
198