Code Duplication    Length = 16-18 lines in 2 locations

src/Darryldecode/Cart/CartCondition.php 1 location

@@ 238-253 (lines=16) @@
235
     * @param $args
236
     * @throws InvalidConditionException
237
     */
238
    protected function validate($args)
239
    {
240
        $rules = array(
241
            'name' => 'required',
242
            'type' => 'required',
243
            'target' => 'required',
244
            'value' => 'required',
245
        );
246
247
        $validator = CartConditionValidator::make($args, $rules);
248
249
        if( $validator->fails() )
250
        {
251
            throw new InvalidConditionException($validator->messages()->first());
252
        }
253
    }
254
}

src/Darryldecode/Cart/Cart.php 1 location

@@ 616-633 (lines=18) @@
613
     * @return array $item;
614
     * @throws InvalidItemException
615
     */
616
    protected function validate($item)
617
    {
618
        $rules = array(
619
            'id' => 'required',
620
            'price' => 'required|numeric',
621
            'quantity' => 'required|numeric|min:1',
622
            'name' => 'required',
623
        );
624
625
        $validator = CartItemValidator::make($item, $rules);
626
627
        if( $validator->fails() )
628
        {
629
            throw new InvalidItemException($validator->messages()->first());
630
        }
631
632
        return $item;
633
    }
634
635
    /**
636
     * add row to cart collection