Code Duplication    Length = 30-31 lines in 2 locations

src/Model/Cart/MyCartDraft.php 1 location

@@ 38-68 (lines=31) @@
35
 * @method MyCartDraft setCustom(CustomFieldObjectDraft $custom = null)
36
 * @method string getLocale()
37
 */
38
class MyCartDraft extends JsonObject
39
{
40
    use LocaleTrait;
41
42
    public function fieldDefinitions()
43
    {
44
        return [
45
            'currency' => [static::TYPE => 'string'],
46
            'customerEmail' => [static::TYPE => 'string'],
47
            'country' => [static::TYPE => 'string'],
48
            'inventoryMode' => [static::TYPE => 'string'],
49
            'lineItems' => [static::TYPE => '\Commercetools\Core\Model\Cart\MyLineItemDraftCollection'],
50
            'shippingAddress' => [static::TYPE => '\Commercetools\Core\Model\Common\Address'],
51
            'billingAddress' => [static::TYPE => '\Commercetools\Core\Model\Common\Address'],
52
            'shippingMethod' => [static::TYPE => '\Commercetools\Core\Model\ShippingMethod\ShippingMethodReference'],
53
            'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'],
54
            'locale' => [static::TYPE => 'string'],
55
        ];
56
    }
57
58
    /**
59
     * @param string $currency
60
     * @param Context|callable $context
61
     * @return CartDraft
62
     */
63
    public static function ofCurrency($currency, $context = null)
64
    {
65
        $draft = static::of($context);
66
        return $draft->setCurrency($currency);
67
    }
68
}
69

src/Model/Category/CategoryDraft.php 1 location

@@ 38-67 (lines=30) @@
35
 * @method LocalizedString getMetaKeywords()
36
 * @method CategoryDraft setMetaKeywords(LocalizedString $metaKeywords = null)
37
 */
38
class CategoryDraft extends JsonObject
39
{
40
    public function fieldDefinitions()
41
    {
42
        return [
43
            'name' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
44
            'slug' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
45
            'description' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
46
            'parent' => [static::TYPE => '\Commercetools\Core\Model\Category\CategoryReference'],
47
            'orderHint' => [static::TYPE => 'string'],
48
            'externalId' => [static::TYPE => 'string'],
49
            'metaDescription' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
50
            'metaTitle' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
51
            'metaKeywords' => [static::TYPE => 'Commercetools\Core\Model\Common\LocalizedString'],
52
            'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'],
53
        ];
54
    }
55
56
    /**
57
     * @param LocalizedString $name
58
     * @param LocalizedString $slug
59
     * @param Context|callable $context
60
     * @return CategoryDraft
61
     */
62
    public static function ofNameAndSlug(LocalizedString $name, LocalizedString $slug, $context = null)
63
    {
64
        $draft = static::of($context);
65
        return $draft->setName($name)->setSlug($slug);
66
    }
67
}
68