-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ETPKIM/1176git_v1' into 'master'
Feature/etpkim/1176git v1 See merge request !2
- Loading branch information
Showing
9 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
/.idea/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Composer stores all downloaded packages in the vendor/ directory. | ||
# Do not use the following if the vendor/ directory is commited to | ||
# your git repository. | ||
cache: | ||
paths: | ||
- vendor/ | ||
|
||
before_script: | ||
# Install composer dependencies | ||
- curl --silent --show-error https://getcomposer.org/installer | php | ||
- php composer.phar install | ||
|
||
test:app: | ||
script: | ||
- ./vendor/bin/phpunit --coverage-text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer require --no-update satooshi/php-coveralls '~1.0' | ||
- travis_retry composer require --no-update sensiolabs/security-checker:dev-master | ||
- travis_retry composer install | ||
|
||
script: | ||
- phpunit --coverage-text --coverage-clover build/logs/clover.xml | ||
|
||
after_success: | ||
- travis_retry php vendor/bin/coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
|
||
## [0.0.0] - 2016-03-24 | ||
### Added | ||
+ Initial release to GitHub. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Lite library to work with arrays | ||
[![Build Status](https://travis-ci.org/ptash/сarray.svg?branch=master)](https://travis-ci.org/ptash/сarray) | ||
[![Coverage Status](https://coveralls.io/repos/github/ptash/сarray/badge.svg?branch=master)](https://coveralls.io/github/ptash/сarray?branch=master) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "cognitive/сarray", | ||
"description": "Library for working with arrays", | ||
"type": "library", | ||
"homepage": "http://www.cognitive.ru/", | ||
"authors": [ | ||
{ | ||
"name": "Cognitive", | ||
"email": "info@cognitive.ru" | ||
} | ||
], | ||
"require-dev": { | ||
"phpunit/phpunit": "^4" | ||
}, | ||
"require": { | ||
"php": ">=5.3" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Cognitive\\CArray\\Test\\": "tests/" | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Cognitive\\CArray\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Git Fixture Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./src</directory> | ||
<exclude> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* CArray.php | ||
*/ | ||
|
||
namespace Cognitive\CArray; | ||
|
||
/** | ||
* Class СArray | ||
* @package Cognitive\СArray | ||
*/ | ||
class CArray | ||
{ | ||
/** | ||
* Checking whether the array is zero-indexed and sequential. | ||
* @param array $arr Input array. | ||
* | ||
* @return bool | ||
*/ | ||
public function isAssociative(array $arr) | ||
{ | ||
if (array() === $arr) { | ||
return false; | ||
} | ||
|
||
$result = array_keys($arr) !== range(0, count($arr) - 1); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/** | ||
* CArrayTest.php | ||
*/ | ||
|
||
namespace Cognitive\CArray\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Cognitive\CArray\CArray; | ||
|
||
/** | ||
* Class CArrayTest | ||
* @package Cognitive\Util\Test | ||
*/ | ||
class CArrayTest extends TestCase | ||
{ | ||
/** | ||
* Data provider for \Cognitive\Util\Test\ArraysTest::testIsAssociative. | ||
* | ||
* @return array | ||
*/ | ||
public function providerTestIsAssociative() | ||
{ | ||
return [ | ||
[ | ||
'data' => [ | ||
'a' => 'a', 'm' => 'b', 'x' => 'c', 1 => 'hello', 5 => 'z', '7' => 'y', 'hello' => 'x' | ||
], | ||
'result' => true, | ||
], | ||
[ | ||
'data' => [ | ||
5 => 'z', 1 => 'hello', '7' => 'y', 'a' => 'a', 'hello' => 'x', 'x' => 'c', 'm' => 'b' | ||
], | ||
'result' => true, | ||
], | ||
[ | ||
'data' => [ | ||
0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd', 4 => 'e', | ||
], | ||
'result' => false, | ||
], | ||
[ | ||
'data' => [ | ||
"1" => 'a', "0" => 'b', "2" => 'c' | ||
], | ||
'result' => true, | ||
], | ||
[ | ||
'data' => [ | ||
"0" => 'a', "1" => 'b', "2" => 'c' | ||
], | ||
'result' => false, | ||
], | ||
[ | ||
'data' => [ | ||
'a', 'b', 'c' | ||
], | ||
'result' => false, | ||
], | ||
[ | ||
'data' => [], | ||
'result' => false | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Array is associative. | ||
* @param array $data Data set. | ||
* @param bool $result Return result after check. | ||
* | ||
* @return void | ||
* | ||
* @dataProvider providerTestIsAssociative | ||
*/ | ||
public function testIsAssociative(array $data, $result) | ||
{ | ||
$arr = new CArray(); | ||
|
||
if ($result === false) { | ||
$message = 'Array type must be not associative'; | ||
$this->assertFalse( | ||
$arr->isAssociative($data), | ||
$message | ||
); | ||
} else { | ||
$message = 'Array type must be associative'; | ||
$this->assertTrue( | ||
$arr->isAssociative($data), | ||
$message | ||
); | ||
} | ||
} | ||
} |