403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/calendar/lib/core/base/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/calendar/lib/core/base/collection.php
<?php

namespace Bitrix\Calendar\Core\Base;

use Countable;
use IteratorAggregate;
use ArrayIterator;

abstract class Collection implements IteratorAggregate, Countable
{
	/**
	 * @var array
	 */
	protected array $collection = [];
	protected ?\Generator $generator = null;

	/**
	 * @param array $collection
	 */
	public function __construct(array $collection = [])
	{
		$this->collection = $collection;
	}

	/**
	 * @return ArrayIterator
	 */
	public function getIterator(): ArrayIterator
	{
		return new ArrayIterator($this->collection);
	}

	/**
	 * @return int
	 */
	public function count(): int
	{
		return count($this->collection);
	}

	/**
	 * @param $item
	 * @return $this
	 */
	public function add($item): Collection
	{
		$this->collection[] = $item;

		if ($this->generator)
		{
			$this->generator->send($item);
		}

		return $this;
	}

	/**
	 * @param array $items
	 * @return $this
	 */
	public function addItems(array $items): Collection
	{

		$this->collection = array_merge($this->collection, $items);

		return $this;
	}

	/**
	 * @param $key
	 *
	 * @return $this
	 */
	public function remove($key): Collection
	{
		unset($this->collection[$key]);

		return $this;
	}

	/**
	 * @return array
	 */
	public function getCollection(): array
	{
		return $this->collection;
	}

	/**
	 * @return mixed
	 *
	 * @throws BaseException
	 */
	public function fetch()
	{
		if ($this->generator === null)
		{
			$this->generator = $this->fetchGenerator();
		}

		$item = $this->generator->current();
		$this->generator->next();

		return $item;
	}

	/**
	 * @return \Generator|null
	 */
	protected function fetchGenerator(): ?\Generator
	{
		if (empty($this->collection))
		{
			return null;
		}

		foreach ($this->collection as $key => $item)
		{
			yield $key => $item;
		}
	}

	/**
	 * @return void
	 */
	public function rewindGenerator(): void
	{
		if (!$this->generator->valid())
		{
			$this->generator->rewind();
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit