Code Duplication    Length = 15-17 lines in 2 locations

src/Darryldecode/Cart/Cart.php 1 location

@@ 697-713 (lines=17) @@
694
     * @return array $item;
695
     * @throws InvalidItemException
696
     */
697
    protected function validate($item)
698
    {
699
        $rules = array(
700
            'id' => 'required',
701
            'price' => 'required|numeric',
702
            'quantity' => 'required|numeric|min:1',
703
            'name' => 'required',
704
        );
705
706
        $validator = CartItemValidator::make($item, $rules);
707
708
        if ($validator->fails()) {
709
            throw new InvalidItemException($validator->messages()->first());
710
        }
711
712
        return $item;
713
    }
714
715
    /**
716
     * add row to cart collection

src/Darryldecode/Cart/CartCondition.php 1 location

@@ 276-290 (lines=15) @@
273
     * @param $args
274
     * @throws InvalidConditionException
275
     */
276
    protected function validate($args)
277
    {
278
        $rules = array(
279
            'name' => 'required',
280
            'type' => 'required',
281
            'value' => 'required',
282
        );
283
284
        $validator = CartConditionValidator::make($args, $rules);
285
286
        if( $validator->fails() )
287
        {
288
            throw new InvalidConditionException($validator->messages()->first());
289
        }
290
    }
291
}
292