2017 © Pedro Peláez
 

library stack-util

A PHP library providing common stack implementation.

image

markenwerk/stack-util

A PHP library providing common stack implementation.

  • Wednesday, October 26, 2016
  • by bonscho
  • Repository
  • 1 Watchers
  • 0 Stars
  • 484 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 19 % Grown

The README.md

PHP Stack Util

Build Status Test Coverage Dependency Status SensioLabs Insight Code Climate Latest Stable Version Total Downloads License, (*1)

A PHP library providing common Stack implementation., (*2)

Installation

```{json} { "require": { "chroma-x/stack-util": "~1.0" } }, (*3)


## Usage ### Autoloading and namesapce ```{php} require_once('path/to/vendor/autoload.php');

Handling a stack

Pushing to the stack

```{php} use ChromaX\StackUtil\Stack;, (*4)

$stack = new Stack();, (*5)

$stack ->push('Item') ->push('Another item') ->push(12) ->push(null) ->push(8.12);, (*6)

$stackSize = $stack->size(); echo 'Stack size: ' . $stackSize . PHP_EOL;, (*7)


##### Output ```{http} Stack size: 5

Reading from the stack

Getting the last item

```{php} $lastItem = $stack->get(); echo 'Last item: ' . $lastItem . PHP_EOL;, (*8)


##### Output ```{http} Last item: 8.12

Getting an item by index

If the index is not available null is returned, (*9)

```{php} $secondItem = $stack->get(1); echo 'Second item: ' . $secondItem . PHP_EOL;, (*10)


##### Output ```{http} Second item: Another item

Popping from the stack

```{php} $poppedItem = $stack->pop(); echo 'Popped item: ' . $poppedItem . PHP_EOL;, (*11)

$stackSize = $stack->size(); echo 'Stack size: ' . $stackSize . PHP_EOL;, (*12)


##### Output ```{http} Popped item: 8.12 Stack size: 4

Updating stacked values

Updating the last item

```{php} $lastItem = $stack ->set('9.12') ->get(); echo 'Updated last item: ' . $lastItem . PHP_EOL;, (*13)


##### Output ```{http} Updated last item: 9.12

Updating an item by index

```{php} $thirdItem = $stack ->set('Third item', 2) ->get(2); echo 'Updated third item: ' . $thirdItem . PHP_EOL;, (*14)


##### Output ```{http} Updated third item: Third item

Removing from the stack

```{php} echo 'Stack size: ' . $stack->size() . PHP_EOL; $stack->delete(1); echo 'Stack size: ' . $stack->size() . PHP_EOL;, (*15)


##### Output ```{http} Stack size: 4 Stack size: 3

Iterating over the stack

Using foreach

```{php} foreach ($stack as $stackItemKey => $stackItemValue) { echo 'Stack item ' . $stackItemKey . ': ' . $stackItemValue . PHP_EOL; }, (*16)


##### Output ```{http} Stack item 0: Item Stack item 1: Third item Stack item 2: 9.12

Using for

```{php} for ($i = 0, $n = $stack->size(); $i < $n; $i++) { echo 'Stack index ' . $i . ': ' . $stack->get($i) . PHP_EOL; }, (*17)


##### Output ```{http} Stack index 0: Item Stack index 1: Third item Stack index 2: 9.12

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document., (*18)

License

PHP Stack Util is under the MIT license., (*19)

The Versions

26/10 2016

dev-master

9999999-dev http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

26/10 2016

1.0.5

1.0.5.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

19/07 2016

1.0.4

1.0.4.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

15/07 2016

1.0.3

1.0.3.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

11/07 2016

1.0.2

1.0.2.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

06/07 2016

1.0.1

1.0.1.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

06/07 2016

1.0.0

1.0.0.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack

06/07 2016

0.0.1

0.0.1.0 http://markenwerk.net/

A PHP library providing common stack implementation.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

stack