Code Duplication    Length = 13-17 lines in 4 locations

src/Api/Translation.php 3 locations

@@ 34-47 (lines=14) @@
31
     *
32
     * @throws Exception
33
     */
34
    public function get(string $projectKey, string $id, string $locale)
35
    {
36
        $response = $this->httpGet(sprintf('/api/translations/%s/%s?key=%s', rawurlencode($id), $locale, $projectKey));
37
38
        if (!$this->hydrator) {
39
            return $response;
40
        }
41
42
        if (200 !== $response->getStatusCode()) {
43
            $this->handleErrors($response);
44
        }
45
46
        return $this->hydrator->hydrate($response, TranslationModel::class);
47
    }
48
49
    /**
50
     * Create a new translation.
@@ 62-74 (lines=13) @@
59
     *
60
     * @throws Exception
61
     */
62
    public function create(string $projectKey, string $id, string $locale, string $translation)
63
    {
64
        $response = $this->httpPostRaw(sprintf('/api/translations/%s/%s?key=%s', rawurlencode($id), $locale, $projectKey), $translation);
65
        if (!$this->hydrator) {
66
            return $response;
67
        }
68
69
        if ($response->getStatusCode() >= 400) {
70
            $this->handleErrors($response);
71
        }
72
73
        return $this->hydrator->hydrate($response, TranslationModel::class);
74
    }
75
76
    /**
77
     * Delete translation
@@ 88-100 (lines=13) @@
85
     *
86
     * @throws Exception
87
     */
88
    public function delete(string $projectKey, string $id, string $locale)
89
    {
90
        $response = $this->httpDelete(sprintf('/api/translations/%s/%s?key=%s', rawurlencode($id), $locale, $projectKey));
91
        if (!$this->hydrator) {
92
            return $response;
93
        }
94
95
        if (200 !== $response->getStatusCode()) {
96
            $this->handleErrors($response);
97
        }
98
99
        return $this->hydrator->hydrate($response, TranslationDeleted::class);
100
    }
101
}
102

src/Api/Asset.php 1 location

@@ 69-85 (lines=17) @@
66
     *
67
     * @throws Exception\DomainException
68
     */
69
    public function tag(string $projectKey, string $id, string $tag)
70
    {
71
        $param = [
72
            'name' => $tag,
73
        ];
74
75
        $response = $this->httpPost(sprintf('/api/assets/%s/tags?key=%s', $id, $projectKey), $param);
76
        if (!$this->hydrator) {
77
            return $response;
78
        }
79
80
        if ($response->getStatusCode() >= 400) {
81
            $this->handleErrors($response);
82
        }
83
84
        return $this->hydrator->hydrate($response, AssetModel::class);
85
    }
86
87
    /**
88
     * Patch an asset.