Code Duplication    Length = 16-18 lines in 2 locations

src/Darryldecode/Cart/CartCondition.php 1 location

@@ 261-276 (lines=16) @@
258
     * @param $args
259
     * @throws InvalidConditionException
260
     */
261
    protected function validate($args)
262
    {
263
        $rules = array(
264
            'name' => 'required',
265
            'type' => 'required',
266
            'target' => '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
}

src/Darryldecode/Cart/Cart.php 1 location

@@ 607-624 (lines=18) @@
604
     * @return array $item;
605
     * @throws InvalidItemException
606
     */
607
    protected function validate($item)
608
    {
609
        $rules = array(
610
            'id' => 'required',
611
            'price' => 'required|numeric',
612
            'quantity' => 'required|numeric|min:1',
613
            'name' => 'required',
614
        );
615
616
        $validator = CartItemValidator::make($item, $rules);
617
618
        if ($validator->fails()) {
619
            throw new InvalidItemException($validator->messages()->first());
620
        }
621
622
        return $item;
623
    }
624
625
    /**
626
     * add row to cart collection
627
     *