Add CoolSMS PHP SDK, and update Composer dependencies

This commit is contained in:
Kijin Sung 2016-11-03 20:19:28 +09:00
parent 40c43e8fa0
commit c719fc0500
242 changed files with 3487 additions and 28983 deletions

View file

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

View file

@ -1,31 +0,0 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
fast_finish: true
include:
- php: 5.3
env: PHPCS=1
sudo: false
before_script:
- composer self-update
- composer install
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then mkdir -p build/logs; fi
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
script:
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then ./vendor/bin/phpunit --coverage-text; fi
- if [[ "$PHPCS" == "1" ]]; then ./vendor/bin/phpcs --standard=PSR2 -np src/ tests/; fi
after_script:
- if [[ "$PHPCS" != "1" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi

View file

@ -1,5 +1,15 @@
# Changelog
## 2.1.0 - 2016-08-09
- [Enhancement] Increase rfc compliance (#20)
- Thanks to [@skroczek](https://github.com/skroczek) for the full patch.
## 2.0.3 - 2016-05-23
- [Fix] Exclude development stuff from repository autogenerated ZIP archives (#18)
- Thanks to [@mlocati](https://github.com/mlocati) for the full patch.
## 2.0.2 - 2016-01-07
- [Fix] Encode and decode domains regardless of their casing (#16)

View file

@ -1,17 +0,0 @@
<?xml version="1.0"?>
<phpunit bootstrap="vendor/autoload.php" colors="true" verbose="true">
<testsuites>
<testsuite name="Punycode Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
<blacklist>
<directory>tests</directory>
<directory>vendor</directory>
</blacklist>
</filter>
</phpunit>

View file

@ -0,0 +1,13 @@
<?php
namespace TrueBV\Exception;
/**
* Class DomainOutOfBoundsException
* @package TrueBV\Exception
* @author Sebastian Kroczek <sk@xbug.de>
*/
class DomainOutOfBoundsException extends OutOfBoundsException
{
}

View file

@ -0,0 +1,13 @@
<?php
namespace TrueBV\Exception;
/**
* Class LabelOutOfBoundsException
* @package TrueBV\Exception
* @author Sebastian Kroczek <sk@xbug.de>
*/
class LabelOutOfBoundsException extends OutOfBoundsException
{
}

View file

@ -0,0 +1,13 @@
<?php
namespace TrueBV\Exception;
/**
* Class OutOfBoundsException
* @package TrueBV\Exception
* @author Sebastian Kroczek <sk@xbug.de>
*/
class OutOfBoundsException extends \RuntimeException
{
}

View file

@ -1,6 +1,9 @@
<?php
namespace TrueBV;
use TrueBV\Exception\DomainOutOfBoundsException;
use TrueBV\Exception\LabelOutOfBoundsException;
/**
* Punycode implementation as described in RFC 3492
*
@ -76,10 +79,19 @@ class Punycode
$input = mb_strtolower($input, $this->encoding);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
$part = $this->encodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return implode('.', $parts);
return $output;
}
/**
@ -146,8 +158,13 @@ class Punycode
$delta++;
$n++;
}
$out = static::PREFIX . $output;
$length = strlen($out);
if ($length > 63 || $length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
return static::PREFIX . $output;
return $out;
}
/**
@ -161,6 +178,10 @@ class Punycode
$input = strtolower($input);
$parts = explode('.', $input);
foreach ($parts as &$part) {
$length = strlen($part);
if ($length > 63 || $length < 1) {
throw new LabelOutOfBoundsException(sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
}
if (strpos($part, static::PREFIX) !== 0) {
continue;
}
@ -168,8 +189,13 @@ class Punycode
$part = substr($part, strlen(static::PREFIX));
$part = $this->decodePart($part);
}
$output = implode('.', $parts);
$length = strlen($output);
if ($length > 255) {
throw new DomainOutOfBoundsException(sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
}
return implode('.', $parts);
return $output;
}
/**

View file

@ -1,151 +0,0 @@
<?php
namespace TrueBV;
class PunycodeTest extends \PHPUnit_Framework_TestCase
{
/**
* Test encoding Punycode
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testEncode($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->encode($decoded);
$this->assertEquals($encoded, $result);
}
/**
* Test decoding Punycode
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testDecode($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->decode($encoded);
$this->assertEquals($decoded, $result);
}
/**
* Test encoding Punycode in uppercase
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testEncodeUppercase($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->encode(mb_strtoupper($decoded, 'UTF-8'));
$this->assertEquals($encoded, $result);
}
/**
* Test decoding Punycode in uppercase
*
* @param string $decoded Decoded domain
* @param string $encoded Encoded domain
* @dataProvider domainNamesProvider
*/
public function testDecodeUppercase($decoded, $encoded)
{
$Punycode = new Punycode();
$result = $Punycode->decode(strtoupper($encoded));
$this->assertEquals($decoded, $result);
}
/**
* Provide domain names containing the decoded and encoded names
*
* @return array
*/
public function domainNamesProvider()
{
return array(
// http://en.wikipedia.org/wiki/.test_(international_domain_name)#Test_TLDs
array(
'مثال.إختبار',
'xn--mgbh0fb.xn--kgbechtv',
),
array(
'مثال.آزمایشی',
'xn--mgbh0fb.xn--hgbk6aj7f53bba',
),
array(
'例子.测试',
'xn--fsqu00a.xn--0zwm56d',
),
array(
'例子.測試',
'xn--fsqu00a.xn--g6w251d',
),
array(
'пример.испытание',
'xn--e1afmkfd.xn--80akhbyknj4f',
),
array(
'उदाहरण.परीक्षा',
'xn--p1b6ci4b4b3a.xn--11b5bs3a9aj6g',
),
array(
'παράδειγμα.δοκιμή',
'xn--hxajbheg2az3al.xn--jxalpdlp',
),
array(
'실례.테스트',
'xn--9n2bp8q.xn--9t4b11yi5a',
),
array(
'בײַשפּיל.טעסט',
'xn--fdbk5d8ap9b8a8d.xn--deba0ad',
),
array(
'例え.テスト',
'xn--r8jz45g.xn--zckzah',
),
array(
'உதாரணம்.பரிட்சை',
'xn--zkc6cc5bi7f6e.xn--hlcj6aya9esc7a',
),
array(
'derhausüberwacher.de',
'xn--derhausberwacher-pzb.de',
),
array(
'renangonçalves.com',
'xn--renangonalves-pgb.com',
),
array(
'рф.ru',
'xn--p1ai.ru',
),
array(
'δοκιμή.gr',
'xn--jxalpdlp.gr',
),
array(
'ফাহাদ্১৯.বাংলা',
'xn--65bj6btb5gwimc.xn--54b7fta0cc',
),
array(
'𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑.gr',
'xn--uba5533kmaba1adkfh6ch2cg.gr',
),
array(
'guangdong.广东',
'guangdong.xn--xhq521b',
),
array(
'gwóźdź.pl',
'xn--gwd-hna98db.pl',
),
);
}
}