Skip to content
This repository was archived by the owner on Aug 13, 2023. It is now read-only.

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Mar 30, 2017
1 parent 3e48d04 commit c41bf0f
Show file tree
Hide file tree
Showing 11 changed files with 483 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
composer.phar
composer.lock
/vendor/
.idea/
build/
28 changes: 28 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
build:
environment:
php:
version: 5.6
tests:
override:
-
command: 'phpunit --coverage-clover=some-file'
coverage:
file: 'some-file'
format: 'clover'
filter:
excluded_paths: [demo/*, tests/*, docs/*]
checks:
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: php
php:
- '5.6'
- '7.0'
- '7.1'
- nightly

before_script:
- "composer require codeclimate/php-test-reporter --dev"
- "composer install"

script:
- "phpunit --coverage-text --coverage-clover build/logs/clover.xml"

after_script:
- CODECLIMATE_REPO_TOKEN="5b094ff7156e13f6d3ceaa2553e5a09a50ee9b483adba253caebe3e9ed7781f3" vendor/bin/test-reporter --stdout > codeclimate.json
- "sh -c 'if [ \"$TRAVIS_PHP_VERSION\" != \"hhvm\" ]; then curl -X POST -d @codeclimate.json -H \"Content-Type: application/json\" -H \"User-Agent: Code Climate (PHP Test Reporter v0.1.1)\" https://codeclimate.com/test_reports ; fi'"

addons:
code_climate:
repo_token: 5b094ff7156e13f6d3ceaa2553e5a09a50ee9b483adba253caebe3e9ed7781f3
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Deimos Project
Copyright (c) 2016 Бабичев Максим

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Slice
Deimos Slice
# DeimosSlice

[![Latest Stable Version](https://poser.pugx.org/deimos/slice/v/stable)](https://packagist.org/packages/deimos/slice)
[![Total Downloads](https://poser.pugx.org/deimos/slice/downloads)](https://packagist.org/packages/deimos/slice)
[![Latest Unstable Version](https://poser.pugx.org/deimos/slice/v/unstable)](https://packagist.org/packages/deimos/slice)
[![License](https://poser.pugx.org/deimos/slice/license)](https://packagist.org/packages/deimos/slice)

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/DeimosProject/Slice/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/DeimosProject/Slice/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/DeimosProject/Slice/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/DeimosProject/Slice/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/DeimosProject/Slice/badges/build.png?b=master)](https://scrutinizer-ci.com/g/DeimosProject/Slice/build-status/master)
10 changes: 10 additions & 0 deletions apigen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source:
- ./src
destination: ./docs
internal: yes
php: no
tree: no
deprecated: yes
todo: yes
sourceCode: no
quiet: no
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "deimos/slice",
"description": "Deimos Slice.",
"keywords": [
"deimos",
"slice"
],
"homepage": "https://github.com/DeimosProject/Slice",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "rez1dent3",
"email": "maksim.babichev95@gmail.com"
}
],
"require": {
"deimos/helper": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "5.7.5"
},
"autoload": {
"psr-4": {
"Deimos\\": "src/"
}
}
}
46 changes: 46 additions & 0 deletions demo/slice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

include_once dirname(__DIR__) . '/vendor/autoload.php';

$builder = new \Deimos\Builder\Builder();
$helper = new \Deimos\Helper\Helper($builder);

$slice = new \Deimos\Slice\Slice($helper, [
'dir' => [
'images' => [
'my' => ['image.jpg'],
'collection' => [
'2017' => [
'praga' => '%collection.2017.praga%'
]
]
]
]
], [
'collection' => [
'2017' => [
'praga' => ['image1.jpg', 'image2.jpg', 'image3.jpg']
]
]
]);

var_dump($slice);

$slice['dir.images.collection.2016'] = [
'praga' => ['image13.jpg', 'image4.jpg']
];

var_dump($slice['dir.images.collection']);

unset($slice['dir.images.collection.2016']);

var_dump($slice->getSlice('dir.images'));
var_dump($slice->getData('dir.images'));

var_dump(isset($slice['dir.images.collection.2016']));
var_dump(isset($slice['dir.images.collection.2017']));

foreach ($slice->getSlice('dir.images') as $key => $slouse)
{
var_dump([$key => $slouse]);
}
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<phpunit bootstrap="tests/bootstrap.php">

<testsuites>
<testsuite name="Config">
<directory>tests/Test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist
addUncoveredFilesFromWhitelist="true"
processUncoveredFilesFromWhitelist="true">

<directory suffix=".php">./src/Config/</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="./build/html/"/>
<log type="coverage-clover" target="./build/logs/clover.xml"/>
</logging>

</phpunit>
95 changes: 95 additions & 0 deletions src/Slice/Iterator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace Deimos\Slice;

use Deimos\Helper\Helper;

class Iterator implements \Countable, \Iterator, \Serializable
{

/**
* @var Helper
*/
protected $helper;

/**
* @var []
*/
protected $storage;

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

/**
* @inheritdoc
*/
public function current()
{
return current($this->storage);
}

/**
* @inheritdoc
*/
public function next()
{
return next($this->storage);
}

/**
* @inheritdoc
*/
public function key()
{
return key($this->storage);
}

/**
* @inheritdoc
*/
public function valid()
{
return $this->key() !== null;
}

/**
* @inheritdoc
*/
public function rewind()
{
reset($this->storage);
}

public function __sleep()
{
return ['storage'];
}

public function __wakeup()
{
$builder = new \Deimos\Builder\Builder();
$this->helper = new \Deimos\Helper\Helper($builder);
}

/**
* @inheritdoc
*/
public function serialize()
{
return serialize($this->storage);
}

/**
* @inheritdoc
*/
public function unserialize($serialized)
{
$this->storage = unserialize($serialized, []);
}

}
Loading

0 comments on commit c41bf0f

Please sign in to comment.