Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
updating for Gotenberg 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gulien committed Aug 23, 2019
1 parent 6776748 commit 195bf7d
Show file tree
Hide file tree
Showing 24 changed files with 173 additions and 218 deletions.
1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ find below useful information about how to contribute to the Gotenberg PHP clien

1. Fork this repository
2. Install Docker and Docker Compose.
3. Install the latest [Orbit](https://github.com/gulien/orbit) release

### Working with git

Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Fixes #
**Checklist**

- [ ] Have you followed the guidelines in our [CONTRIBUTING](CONTRIBUTING.md) guide?
- [ ] Have you lint your code locally prior to submission (`orbit run lint`)?
- [ ] Have you lint your code locally prior to submission (`make lint`)?
- [ ] Have you written new tests for your core changes, as applicable?
- [ ] Have you successfully ran tests with your changes locally (`orbit run up ci`)?
- [ ] Have you successfully ran tests with your changes locally (`make tests`)?
- [ ] I have squashed any insignificant commits
- [ ] This change has comments for package types, values, functions, and non-obvious lines of code
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ language: generic
services:
- docker

before_install:
- wget -qO- https://github.com/gulien/orbit/releases/download/v3.0.1/orbit_Linux_x86_64.tar.gz | tar xvz -C .
- sudo mv ./orbit /usr/local/bin && chmod +x /usr/local/bin/orbit

before_script:
- orbit run up

script:
- orbit run lint tests
- make lint
- make tests
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 TheCodingMachine
Copyright (c) 2019 TheCodingMachine

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
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# start workspace.
workspace:
docker-compose run --rm php bash

# run all linters.
lint:
docker-compose run --rm -T php composer install
docker-compose run --rm -T php composer run csfix
docker-compose run --rm -T php composer run cscheck
docker-compose run --rm -T php composer run phpstan

# run all tests.
test:
docker-compose up -d gotenberg
docker-compose run --rm -T php composer run phpunit
docker-compose down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"thecodingmachine/phpstan-safe-rule": "^0.1.0",
"thecodingmachine/phpstan-strict-rules": "^0.10.7",
"php-http/mock-client": "^1.0",
"php-http/guzzle6-adapter": "^1.1"
"php-http/guzzle6-adapter": "^1.1",
"doctrine/coding-standard": "^6.0"
},
"autoload" : {
"psr-4" : {
Expand All @@ -51,14 +52,14 @@
}
},
"scripts": {
"cs-fix": "phpcbf",
"cs-check": "phpcs",
"csfix": "phpcbf",
"cscheck": "phpcs",
"phpstan": "phpstan analyse src -c phpstan.neon --level=7 --no-progress -vvv",
"phpunit": "phpunit --configuration phpunit.xml.dist"
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "6.0.x-dev"
}
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3'
services:

php:
image: thecodingmachine/php:7.2-v2-cli
image: thecodingmachine/php:7.3-v2-cli
container_name: php
environment:
- PHP_EXTENSION_XDEBUG=1
Expand All @@ -12,6 +12,6 @@ services:
- ./:/usr/src/app:rw

gotenberg:
image: thecodingmachine/gotenberg:5.0.0
image: thecodingmachine/gotenberg:6.0.0
container_name: gotenberg
restart: 'no'
24 changes: 0 additions & 24 deletions orbit.yml

This file was deleted.

48 changes: 36 additions & 12 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
<?xml version="1.0"?>
<ruleset name="Expressive Skeleton coding standard">
<description>Expressive Skeleton coding standard</description>

<!-- display progress -->
<arg value="p"/>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="16"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<!-- Paths to check -->
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>

<exclude-pattern>tests/dependencies/*</exclude-pattern>

<!-- Include full Doctrine Coding Standard -->
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
</rule>

<!-- Do not align assignments -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<severity>0</severity>
</rule>

<!-- Do not align comments -->
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamName">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamType">
<severity>0</severity>
</rule>

<rule ref="Generic.Files.LineLength">
<!-- Require no space before colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="lineLimit" value="300"/>
<property name="absoluteLineLimit" value="500"/>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
</ruleset>
</ruleset>
56 changes: 17 additions & 39 deletions src/ChromeRequest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\Gotenberg;

use function count;

abstract class ChromeRequest extends Request implements GotenbergRequestInterface
{
private const WAIT_DELAY = 'waitDelay';
Expand Down Expand Up @@ -49,28 +53,29 @@ abstract class ChromeRequest extends Request implements GotenbergRequestInterfac
public function getFormValues(): array
{
$values = parent::getFormValues();
if (!is_null($this->waitDelay)) {
if ($this->waitDelay !== null) {
$values[self::WAIT_DELAY] = $this->waitDelay;
}
if (!is_null($this->paperWidth)) {
if ($this->paperWidth !== null) {
$values[self::PAPER_WIDTH] = $this->paperWidth;
}
if (!is_null($this->paperHeight)) {
if ($this->paperHeight !== null) {
$values[self::PAPER_HEIGHT] = $this->paperHeight;
}
if (!is_null($this->marginTop)) {
if ($this->marginTop !== null) {
$values[self::MARGIN_TOP] = $this->marginTop;
}
if (!is_null($this->marginBottom)) {
if ($this->marginBottom !== null) {
$values[self::MARGIN_BOTTOM] = $this->marginBottom;
}
if (!is_null($this->marginLeft)) {
if ($this->marginLeft !== null) {
$values[self::MARGIN_LEFT] = $this->marginLeft;
}
if (!is_null($this->marginRight)) {
if ($this->marginRight !== null) {
$values[self::MARGIN_RIGHT] = $this->marginRight;
}
$values[self::LANDSCAPE] = $this->landscape;

return $values;
}

Expand All @@ -80,25 +85,24 @@ public function getFormValues(): array
public function getFormFiles(): array
{
$files = [];
if (!empty($this->header)) {
if (! empty($this->header)) {
$files['header.html'] = $this->header;
}
if (!empty($this->footer)) {
if (! empty($this->footer)) {
$files['footer.html'] = $this->footer;
}

return $files;
}

/**
* @param float|null $waitDelay
*/
public function setWaitDelay(?float $waitDelay): void
{
$this->waitDelay = $waitDelay;
}

/**
* @param float[] $paperSize
*
* @throws RequestException
*/
public function setPaperSize(array $paperSize): void
Expand All @@ -112,6 +116,7 @@ public function setPaperSize(array $paperSize): void

/**
* @param float[] $margins
*
* @throws RequestException
*/
public function setMargins(array $margins): void
Expand All @@ -125,73 +130,46 @@ public function setMargins(array $margins): void
$this->marginRight = $margins[3];
}

/**
* @param Document|null $header
*/
public function setHeader(?Document $header): void
{
$this->header = $header;
}

/**
* @param Document|null $footer
*/
public function setFooter(?Document $footer): void
{
$this->footer = $footer;
}

/**
* @param float|null $paperWidth
*/
public function setPaperWidth(?float $paperWidth): void
{
$this->paperWidth = $paperWidth;
}

/**
* @param float|null $paperHeight
*/
public function setPaperHeight(?float $paperHeight): void
{
$this->paperHeight = $paperHeight;
}

/**
* @param float|null $marginTop
*/
public function setMarginTop(?float $marginTop): void
{
$this->marginTop = $marginTop;
}

/**
* @param float|null $marginBottom
*/
public function setMarginBottom(?float $marginBottom): void
{
$this->marginBottom = $marginBottom;
}

/**
* @param float|null $marginLeft
*/
public function setMarginLeft(?float $marginLeft): void
{
$this->marginLeft = $marginLeft;
}

/**
* @param float|null $marginRight
*/
public function setMarginRight(?float $marginRight): void
{
$this->marginRight = $marginRight;
}

/**
* @param bool $landscape
*/
public function setLandscape(bool $landscape): void
{
$this->landscape = $landscape;
Expand Down
Loading

0 comments on commit 195bf7d

Please sign in to comment.