Code Duplication    Length = 15-17 lines in 2 locations

src/Darryldecode/Cart/CartCondition.php 1 location

@@ 262-276 (lines=15) @@
259
     * @param $args
260
     * @throws InvalidConditionException
261
     */
262
    protected function validate($args)
263
    {
264
        $rules = array(
265
            'name' => 'required',
266
            'type' => 'required',
267
            'value' => 'required',
268
        );
269
270
        $validator = CartConditionValidator::make($args, $rules);
271
272
        if( $validator->fails() )
273
        {
274
            throw new InvalidConditionException($validator->messages()->first());
275
        }
276
    }
277
}
278

src/Darryldecode/Cart/Cart.php 1 location

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