<?php
namespace Dreamfox\DeliveryDate\Premium\Repositories;

use Dreamfox\DeliveryDate\Interfaces\RepositoryInterface;
use Dreamfox\DeliveryDate\Premium\CommonSetting;

class CommonSettingRepository implements RepositoryInterface
{
  const KEY_DELIVERY_DAYS = 'dreamfox_wdd_premium_delivery_days';

  public function save($item)
  {
    update_option(self::KEY_DELIVERY_DAYS, $item->getDeliveryDays());
  }

  public function load()
  {
    $days = get_option(self::KEY_DELIVERY_DAYS, 0);
    $settings = new CommonSetting();
    $settings->setDeliveryDays($days);
    return $settings;
  }
}