Determine if value exists.

@param string $key Counter key.
@param \DatePeriod $period Date period.
@return \Krucas\Counter\Contracts\Exists|array
484293
public function has($key, \DatePeriod $period = null)
    {
        if (is_null($period)) {
            return new Exists($this->repository->has($key));
        }

        return $this->hasForPeriod($key, $period);
    }
1272101
public function exists( $key ) {
		return ( is_array( $this->data ) && array_key_exists( $key, $this->data ) ) ||
			( is_object( $this->data ) && property_exists( $this->data, $key ) );
	}
1055412
public function has($key)
    {
        $this->fire('checking', $key, [$key]);

        $status = $this->repository->has($this->getKey($key));

        $this->fire('has', $key, [$key, $status]);

        $this->context(null);

        return $status;
    }
802531
public function has($key)
    {
        $values = $this->readFileContents();

        if (!array_key_exists($key, $values)) {
            return false;
        }

        $value = $values[$key];

        return (!$this->hasExpired($value[static::TTL], $value[static::CREATE_TIME]));
    }
1110313
private function processPeriod($period)
    {
        $sub = null;

        if ($period == 'week' || $period == 'W') {
            $sub = \Zend_Date::WEEK;
        } elseif ($period == 'month' || $period == 'M') {
            $sub = \Zend_Date::MONTH;
        } elseif ($period == 'year') {
            $sub = \Zend_Date::YEAR;
        } elseif ($period == 'D') {
            $sub = \Zend_Date::DAY;
        }
        return $sub;
    }
74080
public static function createPeriodKey($period): string
    {
        if ($period->hasFixedDateTimes()) {
            return "{$period->getStartDateTimeString()}|{$period->getEndDateTimeString()}";
        }

        list($subType, $subValueType) = explode('_', strtolower($period->getSubType()));

        return "{$subType}{$period->getSubValue()}{$subValueType}|";
    }
720766
public function has($key)
    {
        // For performance, we can use isset,
        // but it will not match if value == 0
        return isset($this->values[$key]) || array_key_exists($key, $this->values);
    }
905678
public function indexOf(Period $interval)
    {
        foreach ($this->intervals as $offset => $period) {
            if ($period->equals($interval)) {
                return $offset;
            }
        }

        return false;
    }
353640
public function exists($key) {
        if (!array_key_exists($key, $this->storage))
            return false;

        if ($this->storage[$key]['expires'] > 0 && time() > $this->storage[$key]['expires'])
            return false;

        return true;
    }
786901
public function do_exists($key)
    {
        $context = $this->_context;

        return isset($context->data[$key]) && $context->data[$key]['deadline'] >= time();
    }
300181
public function exists(string $key)
    {
        return $this->useRedis(function($resource, $redis) use($key){
            return $redis->hexists($this->getStoreKey(), $key);
        });
    }
245945
public function period(string $period)
    {
        if (!in_array($period, Constants::PERIODS)) {
            throw new InvalidPeriodException('Request period is not valid. Valid values are defined in \Barryvanveen\Lastfm\Constants::PERIODS.');
        }

        $this->query = array_merge($this->query ?? [], ['period' => $period]);

        return $this;
    }
23325
public static function getDatesForPeriod($period)
    {
        /*
         * Type of period is incorrect?
         * Nothing to do
         */
        if (!(new DatePeriod())->isCorrectType($period)) {
            return null;
        }

        $dateStart = null;
        $dateEnd = null;

        switch ($period) {
            case DatePeriod::LAST_WEEK:
                $thisWeekStart = new DateTime('this week');

                $dateStart = clone $thisWeekStart;
                $dateEnd = clone $thisWeekStart;

                $dateStart->sub(new DateInterval('P7D'));
                $dateEnd->sub(new DateInterval('P1D'));

                break;
            case DatePeriod::THIS_WEEK:
                $dateStart = new DateTime('this week');

                $dateEnd = clone $dateStart;
                $dateEnd->add(new DateInterval('P6D'));

                break;
            case DatePeriod::NEXT_WEEK:
                $dateStart = new DateTime('this week');
                $dateStart->add(new DateInterval('P7D'));

                $dateEnd = clone $dateStart;
                $dateEnd->add(new DateInterval('P6D'));

                break;
            case DatePeriod::LAST_MONTH:
                $dateStart = new DateTime('first day of last month');
                $dateEnd = new DateTime('last day of last month');

                break;
            case DatePeriod::THIS_MONTH:
                $lastMonth = self::getDatesForPeriod(DatePeriod::LAST_MONTH);
                $nextMonth = self::getDatesForPeriod(DatePeriod::NEXT_MONTH);

                if (null !== $lastMonth) {
                    $dateStart = $lastMonth->getEndDate();
                    $dateStart->add(new DateInterval('P1D'));
                }

                if (null !== $nextMonth) {
                    $dateEnd = $nextMonth->getStartDate();
                    $dateEnd->sub(new DateInterval('P1D'));
                }

                break;
            case DatePeriod::NEXT_MONTH:
                $dateStart = new DateTime('first day of next month');
                $dateEnd = new DateTime('last day of next month');

                break;
            case DatePeriod::LAST_YEAR:
            case DatePeriod::THIS_YEAR:
            case DatePeriod::NEXT_YEAR:
                $dateStart = new DateTime();
                $dateEnd = new DateTime();

                $yearPeriod = [
                    DatePeriod::LAST_YEAR,
                    DatePeriod::NEXT_YEAR,
                ];

                if (in_array($period, $yearPeriod, true)) {
                    $yearDifference = 1;

                    if (DatePeriod::LAST_YEAR === $period) {
                        $yearDifference *= -1;
                    }

                    $modifyString = sprintf('%s year', $yearDifference);
                    $dateStart->modify($modifyString);
                    $dateEnd->modify($modifyString);
                }

                $year = $dateStart->format('Y');
                $dateStart->setDate($year, 1, 1);
                $dateEnd->setDate($year, 12, 31);

                break;
        }

        /*
         * Start or end date is unknown?
         * Nothing to do
         */
        if (null === $dateStart || null === $dateEnd) {
            return null;
        }

        $dateStart->setTime(0, 0);
        $dateEnd->setTime(23, 59, 59);

        return new DatePeriod($dateStart, $dateEnd);
    }
64218
public function abuts(Period $period)
	    {
	        return $this->start == $period->end || $this->end == $period->start;
	    }
1005396
protected function has($key)
    {
        if (!is_array($key)) {
            return (array_key_exists($key, $this->item));
        }

        foreach ($key as $value) {
            if (!array_key_exists($value, $this->item)) {
                return false;
            }
        }

        return true;
    }
659989
protected function exists($key)
    {
        $data = $this->read($key);
        if ($data === false) {
            return false;
        }

        $expire = $data[0];
        if ($expire !== 0 && $expire < time()) {
            // expired, don't keep it around
            $path = $this->path($key);
            $this->filesystem->delete($path);

            return false;
        }

        return true;
    }
146432
public function exists($key)
	{
		$file = $this->getPath($key);

		return (file_exists($file) && filemtime($file) > time());
	}