Skip to content

Commit

Permalink
chore: lint all files via pint + strict typing
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Jul 26, 2024
1 parent 53a700d commit 2bcd30e
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 74 deletions.
9 changes: 0 additions & 9 deletions phpcs.xml

This file was deleted.

17 changes: 5 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="false"
failOnRisky="true"
failOnWarning="true"
verbose="true">
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd" bootstrap="vendor/autoload.php"
executionOrder="depends,defects" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false">
<testsuites>
<testsuite name="default">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
3 changes: 2 additions & 1 deletion src/Exceptions/ClientClassNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Exceptions;

Expand Down
3 changes: 2 additions & 1 deletion src/Exceptions/CurtainNotSetupException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Exceptions;

Expand Down
3 changes: 2 additions & 1 deletion src/Exceptions/CurtainRequiresWsdlException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Exceptions;

Expand Down
3 changes: 2 additions & 1 deletion src/SoapyBaseClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

Expand Down
3 changes: 2 additions & 1 deletion src/SoapyClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

Expand Down
66 changes: 34 additions & 32 deletions src/SoapyCurtain.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

class SoapyCurtain
{
/** @var string|null */
protected $wsdl = null;
protected ?string $wsdl = null;

/** @var bool */
protected $trace = false;
protected bool $trace = false;

/** @var int */
protected $cache = WSDL_CACHE_NONE;
protected int $cache = WSDL_CACHE_NONE;

/** @var string|null */
protected $location = null;
protected ?string $location = null;

/** @var string|null */
protected $uri = null;
protected ?string $uri = null;

/** @var string */
protected $certificate;
protected ?string $certificate = null;

/** @var array */
protected $options = [];
protected array $options = [];

/** @var array */
protected $classMap;
protected array $classMap = [];

/** @var array */
protected $typeMap;
protected array $typeMap = [];

#region getters
//region getters

public function getWsdl(): ?string
{
Expand Down Expand Up @@ -67,7 +59,7 @@ public function getUri(): ?string
public function getOptions(): array
{
$baseOptions = [
'trace' => $this->getTrace(),
'trace' => $this->getTrace(),
'cache_wsdl' => $this->getCache(),
];

Expand Down Expand Up @@ -104,19 +96,21 @@ public function getTypemap(): ?array
return $this->typeMap;
}

#endregion
//endregion

#region setters
//region setters

public function setWsdl(string $wsdl): self
{
$this->wsdl = $wsdl;

return $this;
}

public function setTrace(bool $flag): self
{
$this->trace = $flag;

return $this;
}

Expand All @@ -125,10 +119,11 @@ public function setCache(int $cache): self
$allowed = [WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY, WSDL_CACHE_BOTH];

if (! in_array($cache, $allowed)) {
throw new \InvalidArgumentException('Cache value passed (' . $allowed . ') is not valid.');
throw new \InvalidArgumentException('Cache value passed ('.$cache.') is not valid.');
}

$this->cache = $cache;

return $this;
}

Expand All @@ -143,67 +138,74 @@ public function setClassMap(array $classmap): self
}

$this->classMap = $classes;

return $this;
}

public function setOptions(array $options): self
{
$this->options = $options;

return $this;
}

public function setCertificate(string $certificate): self
{
$this->certificate = $certificate;

return $this;
}

public function setLocation(string $location): self
{
$this->location = $location;

return $this;
}

public function setUri(string $uri): self
{
$this->uri = $uri;

return $this;
}

public function addTypeMapViaClassName(string $namespace, string $item, string $itemClass)
public function addTypeMapViaClassName(string $namespace, string $item, string $itemClass): self
{
$function = function (string $xml) use ($itemClass) {
$object = simplexml_load_string($xml);

return new $itemClass($object);
};

return $this->addTypeMap($namespace, $item, $function);
}

public function addTypeMap(string $namespace, string $item, \Closure $fromXml)
public function addTypeMap(string $namespace, string $item, \Closure $fromXml): self
{
$typeMap = [
'type_ns' => $namespace,
'type_ns' => $namespace,
'type_name' => $item,
'from_xml' => $fromXml,
'from_xml' => $fromXml,
];

$this->typeMap[] = $typeMap;

return $this;
}

#endregion
//endregion

#region functions
//region functions

public function isReady(): bool
{
if (! empty($this->getLocation()) && ! empty($this->getUri())) {
return true;
}

return !empty($this->getWsdl());
return ! empty($this->getWsdl());
}

#endregion
//endregion
}
6 changes: 4 additions & 2 deletions src/SoapyFacade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

use Illuminate\Support\Facades\Facade;

/**
* Class SoapyFacade
*
* @method static SoapyBaseClient create(\Closure $closure = null, string $client = null)
*/
class SoapyFacade extends Facade
{
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return SoapyTub::class;
}
Expand Down
9 changes: 5 additions & 4 deletions src/SoapyServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

use Illuminate\Support\ServiceProvider;

class SoapyServiceProvider extends ServiceProvider
{
public function boot()
public function boot(): void
{
//
}

public function register()
public function register(): void
{
$this->app->singleton(SoapyTub::class, function () {
return new SoapyTub();
return new SoapyTub;
});
}
}
13 changes: 7 additions & 6 deletions src/SoapyTub.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy;

Expand All @@ -9,28 +10,28 @@

class SoapyTub
{
public function create(\Closure $closure, string $soapClient = null): SoapyBaseClient
public function create(\Closure $closure, ?string $soapClient = null): SoapyBaseClient
{
$curtain = new SoapyCurtain();
$curtain = new SoapyCurtain;

/** @var SoapyCurtain $service */
$service = $closure($curtain);

if (is_null($service)) {
throw new CurtainNotSetupException();
throw new CurtainNotSetupException;
}

/** @var SoapyBaseClient $soapyClient */
$soapyClient = SoapyClient::class;
if (! empty($soapClient)) {
if (! class_exists($soapClient)) {
throw new ClientClassNotFoundException();
throw new ClientClassNotFoundException;
}
$soapyClient = $soapClient;
}

if (! $service->isReady()) {
throw new CurtainRequiresWsdlException();
throw new CurtainRequiresWsdlException;
}

$client = new $soapyClient(
Expand Down
5 changes: 3 additions & 2 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Tests;

Expand All @@ -12,6 +13,6 @@ class BaseTestCase extends TestCase
public function setUp(): void
{
parent::setUp();
$this->baseWsdl = __DIR__ . '/example.wsdl';
$this->baseWsdl = __DIR__.'/example.wsdl';
}
}
3 changes: 2 additions & 1 deletion tests/TestSoapyClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Tests;

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/CustomClassTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

declare(strict_types=1);

namespace Sourcetoad\Soapy\Tests\Unit;

Expand Down

0 comments on commit 2bcd30e

Please sign in to comment.