Skip to content

Commit

Permalink
Merge pull request #5 from detailnet/tweak/php7
Browse files Browse the repository at this point in the history
Tweak/php7
  • Loading branch information
curzio-della-santa committed Jan 14, 2019
2 parents 9cc5e73 + b94569a commit 292687d
Show file tree
Hide file tree
Showing 78 changed files with 1,486 additions and 1,934 deletions.
3 changes: 2 additions & 1 deletion .coveralls.yml
@@ -1,2 +1,3 @@
src_dir: src
service_name: travis-ci
coverage_clover: build/clover.xml
json_path: build/coveralls-upload.json
37 changes: 23 additions & 14 deletions .travis.yml
@@ -1,23 +1,32 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm
env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="php-coveralls/php-coveralls"

matrix:
allow_failures:
- php: hhvm
include:
- php: 7.2
env:
- CS_CHECK=true
- MD_CHECK=true
- TEST_COVERAGE=true
- php: 7.3

before_script:
- composer self-update
- composer install --dev --prefer-source --no-interaction
before_install:
# - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- cp phpunit.xml.dist phpunit.xml

install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- stty cols 120 && composer show

script:
- php vendor/bin/phpunit -c travis.phpunit.xml
- php vendor/bin/phpmd src xml build/config/phpmd.xml --reportfile build/logs/pmd.xml
- php vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v ./src/ ./tests/
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $MD_CHECK == 'true' ]]; then composer md-check ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage-clover ; else composer test ; fi

after_script:
- php vendor/bin/coveralls
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 DETAIL NET
Copyright (c) 2018 DETAIL NET

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 1 addition & 3 deletions README.md
@@ -1,8 +1,6 @@
# blitline
# Blitline API client

[![Build Status](https://travis-ci.org/detailnet/blitline.svg?branch=master)](https://travis-ci.org/detailnet/blitline)
[![Coverage Status](https://img.shields.io/coveralls/detailnet/blitline.svg)](https://coveralls.io/r/detailnet/blitline)
[![Latest Stable Version](https://poser.pugx.org/detailnet/blitline/v/stable.svg)](https://packagist.org/packages/detailnet/blitline)
[![Latest Unstable Version](https://poser.pugx.org/detailnet/blitline/v/unstable.svg)](https://packagist.org/packages/detailnet/blitline)

Blitline API client. http://www.blitline.com
3 changes: 0 additions & 3 deletions build/.gitignore
@@ -1,5 +1,2 @@
*
!config
!config/*
!logs
!.gitignore
31 changes: 0 additions & 31 deletions build/config/phpcs.xml

This file was deleted.

2 changes: 0 additions & 2 deletions build/logs/.gitignore

This file was deleted.

56 changes: 24 additions & 32 deletions composer.json
Expand Up @@ -10,49 +10,41 @@
],
"homepage": "http://www.blitline.com/",
"license": "MIT",
"authors": [
{
"name": "Ivan Wolf",
"email": "ivan.wolf@detailnet.ch"
}
],
"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "^5.0.3",
"guzzlehttp/guzzle-services": "^0.5.0",
"mtdowling/jmespath.php": "~2.2"
"php": "^7.2",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.2",
"guzzlehttp/guzzle-services": "^1.1",
"mtdowling/jmespath.php": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"squizlabs/php_codesniffer" : "~2.3",
"phpmd/phpmd": "~2.2",
"satooshi/php-coveralls": "~1.0"
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer" : "^3.2",
"phpmd/phpmd": "^2.2",
"roave/security-advisories": "dev-master"
},
"autoload": {
"psr-0": {
"psr-4": {
"Detail\\Blitline\\": "src/"
}
},
"autoload-dev": {
"psr-0": {
"psr-4": {
"DetailTest\\Blitline\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"archive": {
"exclude": [
"!vendor",
"tests",
"*phpunit.xml",
".coveralls.yml",
".travis.yml",
"build.xml",
"build.properties",
"composer.phar"
]
"scripts": {
"check": [
"@cs-check",
"@md-check",
"@test"
],
"cs-check": "phpcs --standard=phpcs.xml -v",
"cs-check-report": "phpcs --standard=phpcs.xml --report=checkstyle --report-file=build/checkstyle.xml",
"md-check": "phpmd src xml phpmd.xml",
"md-check-report": "phpmd src xml phpmd.xml --reportfile build/pmd.xml",
"test": "phpunit",
"test-coverage-html": "phpunit --coverage-html build/coverage",
"test-coverage-clover": "phpunit --coverage-clover build/clover.xml"
}
}
4 changes: 2 additions & 2 deletions examples/config.php.dist
@@ -1,7 +1,7 @@
<?php

return array(
return [
'application_id' => 'your-blitline-application-id',
's3bucket' => 'your-bucket-name',
's3prefix' => 'test-files', // Or any other path under your bucket
);
];
4 changes: 2 additions & 2 deletions examples/job-info.php
Expand Up @@ -12,6 +12,6 @@

$blitline = BlitlineClient::factory($config);

$response = $blitline->pollJob(array('job_id' => $jobId));
$response = $blitline->pollJob(['job_id' => $jobId]);

var_dump($response->getResult());
var_dump($response->toArray());
35 changes: 22 additions & 13 deletions examples/job-submit-s3.php
Expand Up @@ -10,7 +10,7 @@
throw new RuntimeException('Missing or invalid parameter "image_key"');
}

$getConfig = function($optionName) use ($config) {
$getConfig = function ($optionName) use ($config) {
if (!isset($config[$optionName])) {
throw new RuntimeException(sprintf('Missing configuration option "%s"', $optionName));
}
Expand All @@ -28,11 +28,11 @@
$jobBuilder = $blitline->getJobBuilder();
$jobBuilder->setDefaultOption(
'function.save',
array(
's3_destination' => array(
[
's3_destination' => [
'bucket' => $getConfig('s3bucket'),
),
)
],
]
);

$job = $jobBuilder->createJob()
Expand All @@ -44,20 +44,20 @@
$jobBuilder->createFunction()
->setName('resize_to_fit')
->setParams(
array(
[
'width' => $imageSize,
'height' => $imageSize,
'only_shrink_larger' => true, // Don't upscale image
)
]
)
->setSaveOptions(
array(
[
'image_identifier' => $imageName,
's3_destination' => array(
// 'bucket' => $getConfig('s3bucket'),
's3_destination' => [
// 'bucket' => $getConfig('s3bucket'),
'key' => $getConfig('s3prefix') . '/' . $imageName . '-' . $imageSize . '_blitline.jpg',
),
)
],
]
)
);

Expand All @@ -67,4 +67,13 @@

$response = $blitline->submitJob($job);

var_dump($response->getResult());
if ($response->hasErrors()) {
var_dump($response->getErrors());
} else {
var_dump(
[
'job_id' => $response->getJobId(),
'images' => $response->getImages(),
]
);
}
35 changes: 22 additions & 13 deletions examples/job-submit.php
Expand Up @@ -10,7 +10,7 @@
throw new RuntimeException('Missing or invalid parameter "image_url"');
}

$getConfig = function($optionName) use ($config) {
$getConfig = function ($optionName) use ($config) {
if (!isset($config[$optionName])) {
throw new RuntimeException(sprintf('Missing configuration option "%s"', $optionName));
}
Expand All @@ -28,11 +28,11 @@
$jobBuilder = $blitline->getJobBuilder();
$jobBuilder->setDefaultOption(
'function.save',
array(
's3_destination' => array(
[
's3_destination' => [
'bucket' => $getConfig('s3bucket'),
),
)
],
]
);

$job = $jobBuilder->createJob()
Expand All @@ -41,20 +41,20 @@
$jobBuilder->createFunction()
->setName('resize_to_fit')
->setParams(
array(
[
'width' => $imageSize,
'height' => $imageSize,
'only_shrink_larger' => true, // Don't upscale image
)
]
)
->setSaveOptions(
array(
[
'image_identifier' => $imageName,
's3_destination' => array(
// 'bucket' => $getConfig('s3bucket'),
's3_destination' => [
// 'bucket' => $getConfig('s3bucket'),
'key' => $getConfig('s3prefix') . '/' . $imageName . '-' . $imageSize . '_blitline.jpg',
),
)
],
]
)
);

Expand All @@ -64,4 +64,13 @@

$response = $blitline->submitJob($job);

var_dump($response->getResult());
if ($response->hasErrors()) {
var_dump($response->getErrors());
} else {
var_dump(
[
'job_id' => $response->getJobId(),
'images' => $response->getImages(),
]
);
}
18 changes: 18 additions & 0 deletions phpcs.xml
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset name="DETAIL NET PHPCS rule set">
<description>The coding standard for a DETAIL NET PHP application</description>

<!-- Include the whole PSR-2 standard -->
<rule ref="PSR2"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="140"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>

<!-- Paths to check -->
<file>examples</file>
<file>src</file>
<file>tests</file>
</ruleset>
File renamed without changes.
26 changes: 6 additions & 20 deletions phpunit.xml.dist
@@ -1,29 +1,15 @@
<phpunit
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
syntaxCheck="true"
>
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<testsuite name="Detail\Blitline Test Suite">
<directory>./tests/DetailTest/Blitline</directory>
<directory>./tests</directory>
</testsuite>

<filter>
<whitelist>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
<log type="coverage-html" target="./build/coverage" title="Detail\Blitline" 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>
<!--<logging>-->
<!--<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>-->
<!--</logging>-->
</phpunit>

0 comments on commit 292687d

Please sign in to comment.