Include composer dependencies in repo

This commit is contained in:
Frederic Guillot
2017-10-25 16:22:10 -07:00
parent c507c54162
commit 9e2b2a32fd
1787 changed files with 123616 additions and 45 deletions

View File

@@ -0,0 +1,3 @@
composer.lock
build/
vendor/

View File

@@ -0,0 +1,14 @@
before_commands:
- "composer install --prefer-dist"
tools:
php_mess_detector: true
php_code_sniffer: true
php_analyzer: true
sensiolabs_security_checker: true
php_code_coverage: true
php_cpd: true
php_pdepend:
excluded_dirs: [vendor/, tests/*]
filter:
excluded_paths: [vendor/]

View File

@@ -0,0 +1,19 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
before_script:
- composer install
before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar update --dev --no-interaction
- mkdir -p build/logs
script:
- php vendor/bin/phpunit --coverage-text

19
vendor/christian-riesen/base32/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2013-2014 Christian Riesen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,60 @@
base32
======
Base32 Encoder/Decoder for PHP according to RFC 4648
[![Build Status](https://secure.travis-ci.org/ChristianRiesen/base32.png)](http://travis-ci.org/ChristianRiesen/base32)
[![HHVM Status](http://hhvm.h4cc.de/badge/christian-riesen/base32.png)](http://hhvm.h4cc.de/package/christian-riesen/base32)
[![Latest Stable Version](https://poser.pugx.org/christian-riesen/base32/v/stable.png)](https://packagist.org/packages/christian-riesen/base32) [![Total Downloads](https://poser.pugx.org/christian-riesen/base32/downloads.png)](https://packagist.org/packages/christian-riesen/base32) [![Latest Unstable Version](https://poser.pugx.org/christian-riesen/base32/v/unstable.png)](https://packagist.org/packages/christian-riesen/base32) [![License](https://poser.pugx.org/christian-riesen/base32/license.png)](https://packagist.org/packages/christian-riesen/base32)
Do you like this? Flattr it:
[![Flattr base32](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/720563/ChristianRiesenbase32-on-GitHub)
Usage
-----
<?php
// Include class or user autoloader
use Base32\Base32;
$string = 'fooba';
$encoded = Base32::encode($string);
// $encoded contains now 'MZXW6YTB'
$decoded = Base32::decode($encoded);
// $decoded is again 'fooba'
About
=====
Use
---
Initially created to work with the [one time password project](https://github.com/ChristianRiesen/otp), yet it can stand alone just as well as [Jordi Boggiano](http://seld.be/) kindly pointed out. It's the only Base32 implementation I could make work that passes the test vectors (and contains unit tests).
Goal
----
Have a RFC compliant Base32 encoder and decoder. The implementation could be improved, but for now, it does the job and has unit tests. Ideally, the class can be enhanced while the unit tests keep passing.
Requirements
------------
PHP 5.3.x+
If you want to run the tests, PHPUnit 3.6 or up is required.
Author
------
Christian Riesen <chris.riesen@gmail.com> http://christianriesen.com
Acknowledgements
----------------
Base32 is mostly based on the work of https://github.com/NTICompass/PHP-Base32

130
vendor/christian-riesen/base32/build.xml vendored Normal file
View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="christianriesen-base32" default="build">
<target name="build" depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpcb"/>
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
<exec executable="bash">
<arg value="-c" />
<arg value="curl -s http://getcomposer.org/installer | php" />
</exec>
<exec executable="php">
<arg value="composer.phar" />
<arg value="install" />
</exec>
</target>
<target name="prepare" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l"/>
<fileset dir="${basedir}/src">
<include name="**/*.php"/>
<modified/>
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php"/>
<modified/>
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv"/>
<arg value="${basedir}/build/logs/phploc.csv"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="pdepend" description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml"/>
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg"/>
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="phpmd" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpmd">
<arg path="${basedir}/src"/>
<arg value="text"/>
<arg value="${basedir}/build/phpmd.xml"/>
</exec>
</target>
<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}/src"/>
<arg value="xml"/>
<arg value="${basedir}/build/phpmd.xml"/>
<arg value="--reportfile"/>
<arg value="${basedir}/build/logs/pmd.xml"/>
</exec>
</target>
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpcs">
<arg value="--standard=${basedir}/build/phpcs.xml"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle"/>
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml"/>
<arg value="--standard=${basedir}/build/phpcs.xml"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd"/>
<arg value="${basedir}/build/logs/pmd-cpd.xml"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log"/>
<arg path="${basedir}/build/logs"/>
<arg value="--source"/>
<arg path="${basedir}/src"/>
<arg value="--output"/>
<arg path="${basedir}/build/code-browser"/>
</exec>
</target>
</project>

View File

@@ -0,0 +1,33 @@
{
"name": "christian-riesen/base32",
"type": "library",
"description": "Base32 encoder/decoder according to RFC 4648",
"keywords": ["base32","encode","decode","rfc4648"],
"homepage": "https://github.com/ChristianRiesen/base32",
"license": "MIT",
"authors": [
{
"name": "Christian Riesen",
"email": "chris.riesen@gmail.com",
"homepage": "http://christianriesen.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"satooshi/php-coveralls": "0.*"
},
"autoload": {
"psr-4": {
"Base32\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="Base32 Test Suite">
<directory suffix="Test.php">tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" title="Base32"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>

View File

@@ -0,0 +1,146 @@
<?php
namespace Base32;
/**
* Base32 encoder and decoder
*
* Last update: 2012-06-20
*
* RFC 4648 compliant
* @link http://www.ietf.org/rfc/rfc4648.txt
*
* Some groundwork based on this class
* https://github.com/NTICompass/PHP-Base32
*
* @author Christian Riesen <chris.riesen@gmail.com>
* @link http://christianriesen.com
* @license MIT License see LICENSE file
*/
class Base32
{
/**
* Alphabet for encoding and decoding base32
*
* @var array
*/
private static $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=';
/**
* Creates an array from a binary string into a given chunk size
*
* @param string $binaryString String to chunk
* @param integer $bits Number of bits per chunk
* @return array
*/
private static function chunk($binaryString, $bits)
{
$binaryString = chunk_split($binaryString, $bits, ' ');
if (substr($binaryString, (strlen($binaryString)) - 1) == ' ') {
$binaryString = substr($binaryString, 0, strlen($binaryString)-1);
}
return explode(' ', $binaryString);
}
/**
* Encodes into base32
*
* @param string $string Clear text string
* @return string Base32 encoded string
*/
public static function encode($string)
{
if (strlen($string) == 0) {
// Gives an empty string
return '';
}
// Convert string to binary
$binaryString = '';
foreach (str_split($string) as $s) {
// Return each character as an 8-bit binary string
$binaryString .= sprintf('%08b', ord($s));
}
// Break into 5-bit chunks, then break that into an array
$binaryArray = self::chunk($binaryString, 5);
// Pad array to be divisible by 8
while (count($binaryArray) % 8 !== 0) {
$binaryArray[] = null;
}
$base32String = '';
// Encode in base32
foreach ($binaryArray as $bin) {
$char = 32;
if (!is_null($bin)) {
// Pad the binary strings
$bin = str_pad($bin, 5, 0, STR_PAD_RIGHT);
$char = bindec($bin);
}
// Base32 character
$base32String .= self::$alphabet[$char];
}
return $base32String;
}
/**
* Decodes base32
*
* @param string $base32String Base32 encoded string
* @return string Clear text string
*/
public static function decode($base32String)
{
// Only work in upper cases
$base32String = strtoupper($base32String);
// Remove anything that is not base32 alphabet
$pattern = '/[^A-Z2-7]/';
$base32String = preg_replace($pattern, '', $base32String);
if (strlen($base32String) == 0) {
// Gives an empty string
return '';
}
$base32Array = str_split($base32String);
$string = '';
foreach ($base32Array as $str) {
$char = strpos(self::$alphabet, $str);
// Ignore the padding character
if ($char !== 32) {
$string .= sprintf('%05b', $char);
}
}
while (strlen($string) %8 !== 0) {
$string = substr($string, 0, strlen($string)-1);
}
$binaryArray = self::chunk($string, 8);
$realString = '';
foreach ($binaryArray as $bin) {
// Pad each value to 8 bits
$bin = str_pad($bin, 8, 0, STR_PAD_RIGHT);
// Convert binary strings to ASCII
$realString .= chr(bindec($bin));
}
return $realString;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Base32;
use Base32\Base32;
/**
* Base32 test case.
*/
class Base32Test extends \PHPUnit_Framework_TestCase
{
/**
* Tests Base32->decode()
*
* Testing test vectors according to RFC 4648
* http://www.ietf.org/rfc/rfc4648.txt
*/
public function testDecode()
{
// RFC test vectors say that empty string returns empty string
$this->assertEquals('', Base32::decode(''));
// these strings are taken from the RFC
$this->assertEquals('f', Base32::decode('MY======'));
$this->assertEquals('fo', Base32::decode('MZXQ===='));
$this->assertEquals('foo', Base32::decode('MZXW6==='));
$this->assertEquals('foob', Base32::decode('MZXW6YQ='));
$this->assertEquals('fooba', Base32::decode('MZXW6YTB'));
$this->assertEquals('foobar', Base32::decode('MZXW6YTBOI======'));
// Decoding a string made up entirely of invalid characters
$this->assertEquals('', Base32::decode('8908908908908908'));
}
/**
* Encoder tests, reverse of the decodes
*/
public function testEncode()
{
// RFC test vectors say that empty string returns empty string
$this->assertEquals('', Base32::encode(''));
// these strings are taken from the RFC
$this->assertEquals('MY======', Base32::encode('f'));
$this->assertEquals('MZXQ====', Base32::encode('fo'));
$this->assertEquals('MZXW6===', Base32::encode('foo'));
$this->assertEquals('MZXW6YQ=', Base32::encode('foob'));
$this->assertEquals('MZXW6YTB', Base32::encode('fooba'));
$this->assertEquals('MZXW6YTBOI======', Base32::encode('foobar'));
}
}

View File

@@ -0,0 +1,5 @@
<?php
$loader = require __DIR__ . '/../vendor/autoload.php';
$loader->add("Base32", __DIR__);
$loader->register();