Skip to content

Commit

Permalink
Merge pull request #26 from CottaCush/features/setup-travis-build
Browse files Browse the repository at this point in the history
[improvements/setup-travis-build]: Setup CI for repository
  • Loading branch information
otaruMendez committed Jul 9, 2019
2 parents f8edc85 + 5b16fed commit a93eead
Show file tree
Hide file tree
Showing 35 changed files with 508 additions and 61 deletions.
32 changes: 32 additions & 0 deletions .travis.yml
@@ -0,0 +1,32 @@
language: php

php:
- 7.0
- 7.1
- 7.2

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

## Cache composer
cache:
directories:
- vendor
- $HOME/.composer/cache
- $HOME/cphalcon

before_script:
- travis_retry composer self-update
- travis_retry composer config --global github-oauth.github.com "$GITHUB_TOKEN"
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- travis_retry composer install --no-interaction --ignore-platform-reqs
- travis_retry vendor/bin/install-phalcon.sh $PHALCON_VERSION
- travis_retry composer require --dev php-coveralls/php-coveralls:~2.0 --ignore-platform-reqs

script:
- vendor/bin/phpcs --standard=psr2 src/
- vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml

after_success:
- sh -c 'php vendor/bin/php-coveralls -v'
7 changes: 7 additions & 0 deletions CONTRIBUTORS.md
@@ -0,0 +1,7 @@
# Contributors


- [Kehinde Ladipo][link-kehinde]


[link-kehinde]: https://github.com/kenny-wealth
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -2,6 +2,8 @@

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-coveralls]][link-coveralls]
[![Total Downloads][ico-downloads]][link-downloads]

Phalcon Utils is a repository for libraries that are used across different phalcon projects.
Expand Down Expand Up @@ -55,14 +57,12 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
[ico-version]: https://img.shields.io/packagist/v/cottacush/phalcon-utils.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/cottacush/phalcon-utils/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/cottacush/phalcon-utils.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/cottacush/phalcon-utils.svg?style=flat-square
[ico-coveralls]: https://coveralls.io/repos/github/CottaCush/phalcon-utils/badge.svg?branch=master
[ico-downloads]: https://img.shields.io/packagist/dt/cottacush/phalcon-utils.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/cottacush/phalcon-utils
[link-travis]: https://travis-ci.org/cottacush/phalcon-utils
[link-scrutinizer]: https://scrutinizer-ci.com/g/cottacush/phalcon-utils/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/cottacush/phalcon-utils
[link-travis]: https://travis-ci.org/CottaCush/phalcon-utils
[link-coveralls]: https://coveralls.io/github/CottaCush/phalcon-utils?branch=master
[link-downloads]: https://packagist.org/packages/cottacush/phalcon-utils
[link-author]: https://github.com/yemexx1
[link-contributors]: ../../contributors
[link-contributors]: CONTRIBUTORS.md
5 changes: 4 additions & 1 deletion composer.json
Expand Up @@ -46,7 +46,10 @@
"pagerfanta/pagerfanta": "^1.0",
"bshaffer/oauth2-server-php": "^1.8",
"league/fractal": "^0.13.0",
"xamin/handlebars.php": "^0.10.4"
"xamin/handlebars.php": "^0.10.4",
"techpivot/phalcon-ci-installer": "~1.0",
"scrutinizer/ocular": "~1.1",
"squizlabs/php_codesniffer": "~2.3"
},
"suggest": {
"redound/phalcon-rest": "Install Phalcon Rest for REST app bootstrap support",
Expand Down
8 changes: 6 additions & 2 deletions phpunit.xml
Expand Up @@ -16,7 +16,11 @@
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<directory suffix=".php">src/Templating/</directory>
<directory suffix=".php">src/Util/</directory>
<directory suffix=".php">src/Validation/</directory>
<directory suffix=".php">src/Templating/</directory>

</whitelist>
</filter>
<logging>
Expand All @@ -26,4 +30,4 @@
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
</phpunit>
6 changes: 3 additions & 3 deletions src/Bootstrap/Bootstrap.php
Expand Up @@ -9,16 +9,16 @@
*/
class Bootstrap
{
protected $_executables;
protected $executables;

public function __construct(...$executables)
{
$this->_executables = $executables;
$this->executables = $executables;
}

public function run(...$args)
{
foreach ($this->_executables as $executable) {
foreach ($this->executables as $executable) {
call_user_func_array([$executable, 'run'], $args);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Constants/HttpStatusCodes.php
Expand Up @@ -109,6 +109,7 @@ class HttpStatusCodes
const INTERNAL_SERVER_ERROR_CODE = 500;
const OK_CODE = 200;
const NOT_FOUND_CODE = 404;
const RESOURCE_CREATED_CODE = 201;


/**
Expand All @@ -120,5 +121,4 @@ public static function getMessage($code)
{
return constant('self::HTTP_' . $code);
}

}
3 changes: 1 addition & 2 deletions src/Controller/FractalController.php
Expand Up @@ -70,8 +70,7 @@ protected function createCollectionResponse(
$modelsToLoad,
$resourceKey = null,
$meta = null
)
{
) {
if ($modelsToLoad instanceof Transformable) {
$modelsToLoad = $modelsToLoad->getModelsToLoad();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Exceptions/ValidatorException.php
Expand Up @@ -2,7 +2,6 @@

namespace PhalconUtils\Exceptions;


use Phalcon\Exception;

/**
Expand All @@ -13,4 +12,4 @@
class ValidatorException extends Exception
{

}
}
15 changes: 11 additions & 4 deletions src/Mailer/MailerHandler.php
Expand Up @@ -49,8 +49,16 @@ public function __construct($username, $password, $smtp_host, $smtp_port, $defau
* @return bool
* @author Adeyemi Olaoye <yemi@cottacush.com>
*/
public function send($text = "", $html = "", $subject = "", $to = [], $from = null, $cc = [], $bcc = [], $params = [])
{
public function send(
$text = "",
$html = "",
$subject = "",
$to = [],
$from = null,
$cc = [],
$bcc = [],
$params = []
) {
$this->failures = [];

if (is_null($from)) {
Expand Down Expand Up @@ -84,5 +92,4 @@ private static function getActualMessage($message, $params)
}
return $message;
}

}
}
1 change: 0 additions & 1 deletion src/Middleware/RequestLoggerMiddleware.php
Expand Up @@ -27,7 +27,6 @@ public function __construct($logTargets = [])
}

$this->logger = new Logger($logTargets);

}

public function beforeExecuteRoute()
Expand Down
3 changes: 1 addition & 2 deletions src/Model/BaseModel.php
Expand Up @@ -231,8 +231,7 @@ public static function getPaginatedData(
TransformerAbstract $transformer = null,
$shouldPaginate = null,
$resourceKey = null
)
{
) {
$shouldPaginate = is_null($shouldPaginate) ? self::shouldPaginate() : $shouldPaginate;
$paginator = null;

Expand Down
2 changes: 1 addition & 1 deletion src/Pagination/PaginationAdapter.php
Expand Up @@ -50,4 +50,4 @@ public function getSlice($offset, $length)
{
return $this->paginateObject->items;
}
}
}
2 changes: 1 addition & 1 deletion src/Pagination/PaginationQueryBuilder.php
Expand Up @@ -26,4 +26,4 @@ public function getPaginate()

return $paginate;
}
}
}
17 changes: 11 additions & 6 deletions src/S3/S3Client.php
Expand Up @@ -27,8 +27,14 @@ class S3Client
* @param null $bucket
* @param null $namespace
*/
public function __construct($awsKey, $awsSecret, $region, $bucket = null, $namespace = null, $version = '2006-03-01')
{
public function __construct(
$awsKey,
$awsSecret,
$region,
$bucket = null,
$namespace = null,
$version = '2006-03-01'
) {
$this->awsKey = $awsKey;
$this->awsSecret = $awsSecret;
$this->bucket = $bucket;
Expand Down Expand Up @@ -93,13 +99,13 @@ public function createObject($local_file_path, $file_name, $bucket = null, $name
if (is_null($bucket) && is_null($this->bucket)) {
$this->addMessage('Invalid bucket');
return false;
} else if (!is_null($this->bucket)) {
} elseif (!is_null($this->bucket)) {
$bucket = $this->bucket;
}

if (is_null($namespace) && is_null($this->namespace)) {
$namespace = '';
} else if (!is_null($this->namespace)) {
} elseif (!is_null($this->namespace)) {
$namespace = $this->namespace;
}

Expand Down Expand Up @@ -139,5 +145,4 @@ public function addMessage($message)
{
$this->error_messages[] = $message;
}

}
}
3 changes: 1 addition & 2 deletions src/Validation/BaseValidation.php
Expand Up @@ -58,8 +58,7 @@ private function getSentenceFromArray(
$twoWordsConnector = ' and ',
$lastWordConnector = null,
$connector = ', '
)
{
) {
if ($lastWordConnector === null) {
$lastWordConnector = $twoWordsConnector;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/RequestValidation.php
Expand Up @@ -15,8 +15,8 @@ class RequestValidation extends BaseValidation
* @author Adeyemi Olaoye <yemi@cottacush.com>
* @return mixed
*/
function initialize()
public function initialize()
{
// TODO: Implement initialize() method.
}
}
}
6 changes: 4 additions & 2 deletions src/Validation/Validators/IMEINumber.php
Expand Up @@ -52,7 +52,9 @@ private function validateImei($imei)
}
$sum += $num;
}
if ((($sum + $imei[14]) % 10) != 0) return false;
if ((($sum + $imei[14]) % 10) != 0) {
return false;
}
return true;
}
}
}
5 changes: 3 additions & 2 deletions src/Validation/Validators/NigerianPhoneNumber.php
Expand Up @@ -24,7 +24,8 @@ public function validate(Validation $validation, $attribute)
{
$includeCountryCode = $this->getOption('must_include_country_code', false);
$includePlus = $this->getOption('must_include_plus', false);
$pattern = '/^' . '[+]' . (($includePlus) ? '' : '?') . (($includeCountryCode) ? '234[0]?' : '((234[0]?)|0)') . '[\d]{10}$/';
$pattern = '/^' . '[+]' . (($includePlus) ? '' : '?') . (($includeCountryCode) ?
'234[0]?' : '((234[0]?)|0)') . '[\d]{10}$/';
$this->setOption('pattern', $pattern);

if (!preg_match($pattern, $validation->getValue($attribute))) {
Expand All @@ -34,4 +35,4 @@ public function validate(Validation $validation, $attribute)
return true;
}
}
}
}
3 changes: 2 additions & 1 deletion src/Validation/Validators/NotExisting.php
@@ -1,6 +1,7 @@
<?php

namespace PhalconUtils\Validation\Validators;

use Phalcon\Validation;

/**
Expand All @@ -27,4 +28,4 @@ public function validate(Validation $validation, $attribute)
}
return $is_valid;
}
}
}

0 comments on commit a93eead

Please sign in to comment.