Skip to content

Commit

Permalink
Merge pull request #2 in DEV-MO/php-library from bugfix/ETS-25_suppor…
Browse files Browse the repository at this point in the history
…t_php7.2 to master

* commit '9251a322f244fbe55f0c9f1a78e22487fad9d459':
  [ETS-25] update README file
  [ETS-25] add ci-pipeline support
  [ETS-25] add support for php-7.2
  • Loading branch information
eiriarte-mendez committed Aug 1, 2018
2 parents 92249fd + 9251a32 commit 621de50
Show file tree
Hide file tree
Showing 26 changed files with 476 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ composer.lock
#ignore SDK files
example*
helper*
ratepay_credentials.php
ratepay_credentials.php
build/
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
pipeline {

agent {
label "php"
}

triggers {
pollSCM('H */4 * * 1-5')
}

stages {
stage('Build') {
steps {
echo "[STAGE] Build"
sh "if [ -d build ]; then rm -rf build ; fi && mkdir -p build/logs"
sh "composer install"
}
}
stage('Test') {
steps {
echo "[STAGE] Test"
sh (
returnStatus: true,
script: "phpcs --report=checkstyle --report-file=./build/logs/checkstyle.xml --standard=PSR2 --extensions=php src/"
)

sh (
returnStatus: true,
script: "phpmd src/ xml codesize,cleancode,design,naming,unusedcode,controversial --reportfile build/logs/pmd.xml"
)

// sh '''vendor/bin/phpunit --log-junit=build/junit.xml --coverage-html=build/coverage --coverage-clover=build/clover.xml'''
}
}
stage('Report') {
steps {
echo "[STAGE] Report"
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'build/logs/checkstyle.xml', unHealthy: ''
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'build/logs/pmd.xml', unHealthy: ''
// junit 'build/junit.xml'
}
}
stage('Sonarqube') {
agent { label "master" }
when {
branch 'master'
}
steps {
script {
def scannerHome = tool name: 'SonarQube Scanner 3.0.1', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
echo "scannerHome = $scannerHome ...."
withSonarQubeEnv() {
sh "$scannerHome/bin/sonar-scanner -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN"
}
}
}
}
stage('Deploy') {
steps {
echo "[STAGE] Deploy"
}
}
}

// post {
// always {
// node('master') {
// step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "e.iriarte-mendez@ratepay.com", sendToIndividuals: true])
// }
// }
// }
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
|Repository | Common RatePAY PHP Library
|------|----------
|Author | Aarne Welschlau, Annegret Seufert
|Version | `0.9.5`
|Version | `0.9.6`
|Link | http://www.ratepay.com
|Mail | integration@ratepay.com
22 changes: 22 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">

<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>

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

</phpunit>
14 changes: 14 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# must be unique in a given SonarQube instance
sonar.projectKey=devmo-php-library
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=DevMO PHP-Library
sonar.projectVersion=0.9.4.3

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

sonar.exclusions=tests/**/*,vendor/**/*
6 changes: 3 additions & 3 deletions src/Frontend/DeviceFingerprintBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getToken()
public function getDfpSnippetCode($smarty = false)
{
$snippet = sprintf(
(!$smarty) ? "<script language=\"JavaScript\">var di = %s;</script>" : "<script language=\"JavaScript\">{literal}var di = %s;{/literal}</script>",
(!$smarty) ? '<script language="JavaScript">var di = %s;</script>' : '<script language="JavaScript">{literal}var di = %s;{/literal}</script>',
json_encode([
't' => $this->token,
'v' => $this->snippetId,
Expand All @@ -100,13 +100,13 @@ public function getDfpSnippetCode($smarty = false)
);

$snippet .= sprintf(
"<script type=\"text/javascript\" src=\"%s/%s/di.js\"></script>",
'<script type="text/javascript" src="%s/%s/di.js"></script>',
$this->uri,
$this->snippetId
);

$snippet .= sprintf(
"<noscript><link rel=\"stylesheet\" type=\"text/css\" href=\"%s/di.css?t=%s&v=%s&l=%s\"></noscript>",
'<noscript><link rel="stylesheet" type="text/css" href="%s/di.css?t=%s&v=%s&l=%s"></noscript>',
$this->uri,
$this->token,
$this->snippetId,
Expand Down
6 changes: 6 additions & 0 deletions src/Frontend/DirectDebitBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class DirectDebitBuilder
*/
private $lang;

/**
* DirectDebitBuilder constructor.
* @param string $language
* @throws \RatePAY\Exception\LanguageException
*/
public function __construct($language = "DE")
{
$this->lang = new LanguageService($language);
Expand All @@ -24,6 +29,7 @@ public function __construct($language = "DE")
* Sets current language
*
* @param $language
* @throws \RatePAY\Exception\LanguageException
*/
public function setLanguage($language)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Frontend/InstallmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function setSecuritycode($securitycode)
* Sets current language
*
* @param $language
* @throws \RatePAY\Exception\LanguageException
*/
public function setLanguage($language)
{
Expand Down Expand Up @@ -169,6 +170,7 @@ private function getInstallmentConfiguration()
* @param float $amount
* @param string $template
* @return string
* @throws RequestException
*/
public function getInstallmentCalculatorByTemplate($amount, $template)
{
Expand All @@ -193,6 +195,7 @@ public function getInstallmentCalculatorByTemplate($amount, $template)
*
* @param $amount
* @return string
* @throws RequestException
*/
public function getInstallmentCalculatorAsJson($amount)
{
Expand All @@ -210,8 +213,13 @@ public function getInstallmentCalculatorAsJson($amount)
/**
* Calls CalculationRequest
*
* @param $type
* @param $value
* @param $amount
* @param null $firstday
* @return CalculationRequest
* @throws RequestException
* @throws \RatePAY\Exception\ModelException
*/
private function getInstallmentCalculation($type, $value, $amount, $firstday = null)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Model/Request/SubModel/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function __construct()
{
array_walk($this->admittedFields, function (&$value) {
if (key_exists('instanceOf', $value)) {
$namespace = __NAMESPACE__;
$value['instanceOf'] = __NAMESPACE__ . "\\" . $value['instanceOf'];
}
});
Expand All @@ -39,6 +38,8 @@ public function __construct()
* @param $name
* @param $arguments
* @return bool|null
* @throws ModelException
* @throws RequestException
*/
public function __call($name, $arguments) {
$action = substr($name, 0, 3);
Expand All @@ -65,6 +66,7 @@ public function __call($name, $arguments) {
* @param $field
* @param $arguments
* @return $this
* @throws ModelException
*/
public function commonSetter($field, $arguments) {
if (is_array($arguments) && $arguments[0] !== "") {
Expand Down Expand Up @@ -110,6 +112,8 @@ public function commonGetter($field) {
* Return all values as Array
*
* @return array
* @throws ModelException
* @throws RuleSetException
*/
public function toArray()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Request/SubModel/Content/ShoppingBasket.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class ShoppingBasket extends AbstractModel
* Totalizes item amounts and sets shopping basket amount.
*
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ protected function rule()
* Changes discount to negative value (if necessary)
*
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class Shipping extends AbstractModel
'AutoDelivery' => false
];

/**
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
$this->admittedFields['UnitPriceGross']['value'] = Util::changeAmountToFloat($this->admittedFields['UnitPriceGross']['value']);
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Request/SubModel/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class Head extends AbstractModel
public function toArray()
{
if (!key_exists('value', $this->admittedFields['Meta'])) {
$this->admittedFields['Meta']['value'] = new $this->admittedFields['Meta']['instanceOf'];
$prototype = $this->admittedFields['Meta']['instanceOf'];
$this->admittedFields['Meta']['value'] = new $prototype;
}

return parent::toArray();
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Request/SubModel/Head/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class Meta extends AbstractModel
public function toArray()
{
if (!key_exists('value', $this->admittedFields['Systems'])) {
$this->admittedFields['Systems']['value'] = new $this->admittedFields['Systems']['instanceOf'];
$prototype = $this->admittedFields['Systems']['instanceOf'];
$this->admittedFields['Systems']['value'] = new $prototype;
}

return parent::toArray();
Expand Down
5 changes: 4 additions & 1 deletion src/Model/Request/SubModel/Head/Meta/Systems.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ class Systems extends AbstractModel
* Manipulates the parent method to set instance of systems if not already set
*
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
if (!key_exists('value', $this->admittedFields['System'])) {
$this->admittedFields['System']['value'] = new $this->admittedFields['System']['instanceOf'];
$prototype = $this->admittedFields['System']['instanceOf'];
$this->admittedFields['System']['value'] = new $prototype;
}

return parent::toArray();
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Request/SubModel/Head/Meta/Systems/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class System extends AbstractModel
* Manipulates the parent method to merge set system name and version with default
*
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Request/TraitRequestContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

trait TraitRequestContent
{

/**
* @var Content
*/
Expand Down Expand Up @@ -37,6 +36,8 @@ public function setContent(Content $content)
* Returns all values as Array
*
* @return array
* @throws \RatePAY\Exception\ModelException
* @throws \RatePAY\Exception\RuleSetException
*/
public function toArray()
{
Expand Down
3 changes: 3 additions & 0 deletions src/ModelBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct($modelName = null)
* @param $name
* @param $arguments
* @return mixed|ModelBuilder
* @throws ModelException
*/
public function __call($name, $arguments)
{
Expand Down Expand Up @@ -95,6 +96,7 @@ private function setModel($model)
* Sets and fills model instance by array
*
* @param $array
* @throws ModelException
*/
public function setArray($array)
{
Expand All @@ -117,6 +119,7 @@ public function setArray($array)
* Converts JSON input to array and uses setArray method
*
* @param $json
* @throws ModelException
*/
public function setJson($json) {
$this->setArray(json_decode($json, true));
Expand Down
Loading

0 comments on commit 621de50

Please sign in to comment.