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

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