This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/lib/Rails/ActionView/Helper/Methods/Text.php

33 lines
917 B
PHP
Raw Normal View History

2013-10-02 18:14:53 +02:00
<?php
namespace Rails\ActionView\Helper\Methods;
trait Text
{
private $_cycle_count = 0,
$_cycle_vars = [];
public function cycle()
{
$args = func_get_args();
# Clear vars if null was passed.
if (count($args) == 1 && $args[0] === []) {
$this->_cycle_vars = [];
$this->_cycle_count = 0;
return;
# Reset cycle if new options were given.
} elseif ($this->_cycle_vars && $this->_cycle_vars !== $args) {
$this->_cycle_vars = [];
$this->_cycle_count = 0;
}
if (empty($this->_cycle_vars))
$this->_cycle_vars = $args;
if ($this->_cycle_count > count($this->_cycle_vars) - 1)
$this->_cycle_count = 0;
$value = $this->_cycle_vars[$this->_cycle_count];
$this->_cycle_count++;
return $value;
}
}