Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
20 changes: 20 additions & 0 deletions .docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* This file is part of eldnp/export.zend.
*
* Eldnp/export.zend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eldnp/export.zend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with eldnp/export.zend. If not, see <http://www.gnu.org/licenses/>.
*
* @see https://github.com/eldnp/export.zend for the canonical source repository
* @copyright Copyright (c) %regexp:(20\d{2}-)?20\d{2}% Oleg Verevskoy <verevskoy@gmail.com>
* @license https://github.com/eldnp/export.zend/blob/master/LICENSE GNU GENERAL PUBLIC LICENSE Version 3
*/
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.coveralls.yml export-ignore
/.docheader export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
/test export-ignore
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
composer.phar
/vendor/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
.idea/
vendor/
composer.lock
phpunit.xml
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
sudo: false

language: php

cache:
directories:
- $HOME/.composer/cache

env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"

matrix:
include:
- php: 5.3
dist: precise
env:
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 5.4
dist: precise
- php: 5.5
dist: precise
- php: 5.6

before_install:
- if [[ $TEST_COVERAGE != 'true' && "$(php --version | grep xdebug -ci)" -ge 1 ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- travis_retry composer self-update

install:
- travis_retry composer install $COMPOSER_ARGS
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- stty cols 120 && composer show
script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

notifications:
email: false
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# export.zend

[![Build Status](https://travis-ci.org/eldnp/export.zend.svg?branch=master)](https://travis-ci.org/eldnp/export.zend)
[![Coverage Status](https://coveralls.io/repos/github/eldnp/export.zend/badge.svg?branch=master)](https://coveralls.io/github/eldnp/export.zend?branch=master)

export.zend
48 changes: 48 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "eldnp/export.zend",
"type": "library",
"license": "GPL-3.0",
"authors": [
{
"name": "Oleg Verevskoy",
"email": "verevskoy@gmail.com",
"role": "Developer"
}
],
"extra": {
"branch-alias": {
"dev-master": "0.1-dev",
"dev-develop": "0.2-dev"
}
},
"autoload": {
"psr-4": {
"Eldnp\\Export\\Zend\\": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"EldnpTest\\Export\\Zend\\": "test/"
}
},
"require": {
"php": "^5.3",
"eldnp/export.map": "^0.2",
"zendframework/zend-inputfilter": "^2.5"
},
"require-dev": {
"phpunit/PHPUnit": "^4.8",
"zendframework/zend-coding-standard": "~1.0.0"
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"upload-coverage": "coveralls -v",
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --coverage-clover clover.xml"
}
}
125 changes: 125 additions & 0 deletions lib/DataSource/FilterableDataSourceDecorator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php
/*
* This file is part of eldnp/export.zend.
*
* Eldnp/export.zend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eldnp/export.zend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with eldnp/export.zend. If not, see <http://www.gnu.org/licenses/>.
*
* @see https://github.com/eldnp/export.zend for the canonical source repository
* @copyright Copyright (c) 2017 Oleg Verevskoy <verevskoy@gmail.com>
* @license https://github.com/eldnp/export.zend/blob/master/LICENSE GNU GENERAL PUBLIC LICENSE Version 3
*/

namespace Eldnp\Export\Zend\DataSource;

use Eldnp\Export\Map\AbstractMapDataSource;
use Zend\InputFilter\InputFilterInterface;

/**
* Class FilterableDataSourceDecorator
*
* @package Eldnp\Export\Zend\DataSource
*/
class FilterableDataSourceDecorator extends AbstractMapDataSource
{
/**
* @var AbstractMapDataSource
*/
private $dataSource;

/**
* @var InputFilterInterface
*/
private $inputFilter;

/**
* @var ValidationCallbackHandlerInterface
*/
private $validationCallbackHandler;

/**
* @var array
*/
private $currentData;

/**
* FilterableDataSourceDecorator constructor.
*
* @param AbstractMapDataSource $dataSource
* @param InputFilterInterface $inputFilter
* @param ValidationCallbackHandlerInterface $validationCallbackHandler
*/
public function __construct(
AbstractMapDataSource $dataSource,
InputFilterInterface $inputFilter,
ValidationCallbackHandlerInterface $validationCallbackHandler
) {
$this->dataSource = $dataSource;
$this->inputFilter = $inputFilter;
$this->validationCallbackHandler = $validationCallbackHandler;
}

/**
* @inheritdoc
*/
protected function currentMap()
{
return $this->currentData;
}

/**
* @inheritdoc
*/
public function next()
{
do {
$this->currentData = false;
$this->dataSource->next();
if (false === $this->dataSource->valid()) {
return;
}
$newData = $this->dataSource->current();
$this->inputFilter->setData($newData);
if (!$this->inputFilter->isValid()) {
$this->validationCallbackHandler->handle($this->inputFilter->getMessages());
continue;
}
$this->currentData = $this->inputFilter->getValues();
return;
} while (true);
}

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

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

/**
* @inheritdoc
*/
public function rewind()
{
$this->dataSource->rewind();
}
}
38 changes: 38 additions & 0 deletions lib/DataSource/ValidationCallbackHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of eldnp/export.zend.
*
* Eldnp/export.zend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eldnp/export.zend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with eldnp/export.zend. If not, see <http://www.gnu.org/licenses/>.
*
* @see https://github.com/eldnp/export.zend for the canonical source repository
* @copyright Copyright (c) 2017 Oleg Verevskoy <verevskoy@gmail.com>
* @license https://github.com/eldnp/export.zend/blob/master/LICENSE GNU GENERAL PUBLIC LICENSE Version 3
*/

namespace Eldnp\Export\Zend\DataSource;

/**
* Interface ValidationCallbackHandlerInterface
*
* @package Eldnp\Export\Zend\DataSource
*/
interface ValidationCallbackHandlerInterface
{
/**
* @param array $messages
*
* @return void
*/
public function handle(array $messages);
}
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset name="Eldorado coding standard">
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml">
<exclude name="Generic.Arrays.DisallowLongArraySyntax"/>
<exclude name="Generic.Formatting.SpaceAfterNot"/>
</rule>
<file>lib</file>
</ruleset>
27 changes: 27 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="eldnp/export.data-source.dto test suite">
<directory>./test/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib</directory>
</whitelist>
</filter>

<php>
<ini name="date.timezone" value="UTC"/>
</php>
</phpunit>
Loading