Skip to content

Commit

Permalink
Merge pull request #38 from i-doit/release-1.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
leonardfischer authored Dec 17, 2024
2 parents b920f1f + 0cccef9 commit 986a51a
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 100 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
experimental: [false]
include:
- php-versions: nightly
Expand Down
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased][]

Spring clean 2022!
## [1.0.0][] – 2024-12-16

**Note:** Support for all PHP `7` versions has been dropped. PHP `8+` only, from now on :)

### Added

- `Idoit::search()`, `Idoit::batchSearch`: Add search modes "normal" (default), "deep" and "auto-deep"
- Support for PHP `8.3`

### Changed

- **Breaking:** Change Composer package to `idoit/apiclient`
- **Breaking:** Change PHP namespace to `Idoit\APIClient`
- **Breaking:** Move repository to `github.com/i-doit/api-client-php`
- **Breaking:** Require at least PHP version `8.0`
- Recommend PHP version `8.1`
- Recommend PHP version `8.2`
- **Breaking:** Require at least i-doit `1.18.1` and its API add-on `1.12.3`

### Deprecated

- Deprecate support of PHP version `7.4`

### Removed

- **Breaking:** Drop support of PHP version `7.1`, `7.2`, and `7.3`
- **Breaking:** Drop support of PHP version `7.1`, `7.2`, `7.3` and `7.4`

## [0.10][] – 2020-04-07

Expand Down Expand Up @@ -234,7 +233,8 @@ Happy summer time ⛱️

Initial release

[Unreleased]: https://github.com/i-doit/api-client-php/compare/0.10...HEAD
[Unreleased]: https://github.com/i-doit/api-client-php/compare/1.0.0...HEAD
[1.0.0]: https://github.com/i-doit/api-client-php/compare/0.10...1.0.0
[0.10]: https://github.com/i-doit/api-client-php/compare/0.9...0.10
[0.9]: https://github.com/i-doit/api-client-php/compare/0.8...0.9
[0.8]: https://github.com/i-doit/api-client-php/compare/0.7...0.8
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"source": "https://github.com/i-doit/api-client-php"
},
"require": {
"php": "^8.0 || ^8.1 || ^8.2",
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3",
"ext-curl": "*",
"ext-date": "*",
"ext-json": "*",
Expand All @@ -35,23 +35,23 @@
"require-dev": {
"ext-dom": "*",
"ext-xml": "*",
"brianium/paratest": "^6.4",
"brianium/paratest": "^6.11",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"j13k/yaml-lint": "^1.1",
"phan/phan": "^5.3",
"phan/phan": "^5.4",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpcompatibility/php-compatibility": "^9.3",
"phploc/phploc": "^7.0",
"phpmd/phpmd": "^2.12",
"phpstan/phpstan": "^1.7",
"phpunit/phpunit": "^9.5",
"phpmd/phpmd": "^2.15",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.6",
"povils/phpmnd": "^2.5",
"psalm/phar": "^4.23",
"psalm/phar": "^5.26",
"roave/security-advisories": "dev-master",
"sclable/xml-lint": "^0.8.0",
"sebastian/phpcpd": "^6.0",
"seld/jsonlint": "^1.9",
"squizlabs/php_codesniffer": "^3.6",
"seld/jsonlint": "^1.11",
"squizlabs/php_codesniffer": "^3.11",
"symfony/dotenv": "^5.4"
},
"suggest": {
Expand Down
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
parameters:
level: 5
checkMissingIterableValueType: false
paths:
- src
- tests
ignoreErrors:
# Ignore skipped tests:
- message: "#Unreachable statement#"
paths:
- tests/Idoit/APIClient/*
47 changes: 20 additions & 27 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.0/phpunit.xsd"
bootstrap="./vendor/autoload.php"
cacheTokens="false"
colors="true"
timeoutForSmallTests="10"
timeoutForMediumTests="30"
timeoutForLargeTests="120"
verbose="true">
<testsuites>
<testsuite name="Unit Tests">
<directory>./tests/Idoit/APIClient/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-text" target="php://stdout"/>
</logging>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<extensions>
<extension class="Idoit\APIClient\Extension\PrintMetaData"/>
<extension class="Idoit\APIClient\Extension\PrintStatistics"/>
</extensions>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true" timeoutForSmallTests="10" timeoutForMediumTests="30" timeoutForLargeTests="120" verbose="true">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
<report>
<text outputFile="php://stdout"/>
</report>
</coverage>
<testsuites>
<testsuite name="Unit Tests">
<directory>./tests/Idoit/APIClient/</directory>
</testsuite>
</testsuites>
<logging/>
<extensions>
<extension class="Idoit\APIClient\Extension\PrintMetaData"/>
<extension class="Idoit\APIClient\Extension\PrintStatistics"/>
</extensions>
</phpunit>
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
phpVersion="7.4"
phpVersion="8.0"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
Expand Down
15 changes: 9 additions & 6 deletions src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ class API {
/**
* cURL resource
*
* @var CurlHandle|resource|false|null
* @var CurlHandle|null
*/
protected $resource;
protected CurlHandle|null $resource = null;

/**
* Information about last client request
Expand Down Expand Up @@ -247,7 +247,7 @@ public function __destruct() {
* @return bool
*/
public function isConnected(): bool {
return is_resource($this->resource) || $this->resource instanceof CurlHandle;
return $this->resource instanceof CurlHandle;
}

/**
Expand Down Expand Up @@ -346,12 +346,14 @@ protected function setCURLOptions(): self {
* @throws RuntimeException on error
*/
public function connect(): self {
$this->resource = curl_init();
$curl = curl_init();

if ($this->resource == false) {
if (!$curl instanceof CurlHandle) {
throw new RuntimeException('Unable to initiate cURL session');
}

$this->resource = $curl;

return $this;
}

Expand All @@ -371,6 +373,7 @@ public function disconnect(): self {
}

curl_close($this->resource);
$this->resource = null;

return $this;
}
Expand Down Expand Up @@ -619,7 +622,7 @@ protected function execute(array $data): array {
$lastResponse = json_decode(trim($body), true);

if (!is_array($lastResponse)) {
if (is_string($body) && strlen($body) > 0) {
if (strlen($body) > 0) {
throw new RuntimeException(sprintf(
'i-doit responded with an unknown message: %s',
$body
Expand Down
16 changes: 8 additions & 8 deletions src/CMDBCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function save(int $objectID, string $categoryConstant, array $attributes,
*/
public function create(int $objectID, string $categoryConst, array $attributes): int {
$params = [
'objID' => $objectID,
'object' => $objectID,
'data' => $attributes,
'category' => $categoryConst
];

$result = $this->api->request(
'cmdb.category.create',
'cmdb.category.save',
$params
);

Expand Down Expand Up @@ -217,9 +217,9 @@ public function update(int $objectID, string $categoryConst, array $attributes,
}

$result = $this->api->request(
'cmdb.category.update',
'cmdb.category.save',
[
'objID' => $objectID,
'object' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
Expand Down Expand Up @@ -376,13 +376,13 @@ public function batchCreate(array $objectIDs, string $categoryConst, array $attr
foreach ($objectIDs as $objectID) {
foreach ($attributes as $data) {
$params = [
'objID' => $objectID,
'object' => $objectID,
'data' => $data,
'category' => $categoryConst
];

$requests[] = [
'method' => 'cmdb.category.create',
'method' => 'cmdb.category.save',
'params' => $params
];
}
Expand Down Expand Up @@ -493,9 +493,9 @@ public function batchUpdate(array $objectIDs, string $categoryConst, array $attr

foreach ($objectIDs as $objectID) {
$requests[] = [
'method' => 'cmdb.category.update',
'method' => 'cmdb.category.save',
'params' => [
'objID' => $objectID,
'object' => $objectID,
'category' => $categoryConst,
'data' => $attributes
]
Expand Down
8 changes: 1 addition & 7 deletions src/CMDBCategoryInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,7 @@ public function readAll(): array {

$categories = $this->batchRead($cleanCategoryConstants);

$combinedArray = array_combine($cleanCategoryConstants, $categories);

if (!is_array($combinedArray)) {
throw new RuntimeException('Unable to restructure result');
}

return $combinedArray;
return array_combine($cleanCategoryConstants, $categories);
}

/**
Expand Down
Loading

0 comments on commit 986a51a

Please sign in to comment.