Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vendor
node_modules
.phpactor.json
build
.phpunit.cache

## Annotations
src/DTO/Documents/AnnotationsStamps/*
Expand Down
1 change: 0 additions & 1 deletion .phpunit.cache/test-results

This file was deleted.

46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,52 @@ $connector = new DocuWareConnector(
);
```

### Enums

The package provides several enums to ensure type safety and consistency when working with DocuWare API values.

#### ConnectionEnum

Represents different connection types for DocuWare authentication:

```php
use CodebarAg\DocuWare\Enums\ConnectionEnum;

ConnectionEnum::WITHOUT_COOKIE;
ConnectionEnum::STATIC_COOKIE;
ConnectionEnum::DYNAMIC_COOKIE;
```

#### DialogType

Represents different types of dialogs in DocuWare:

```php
use CodebarAg\DocuWare\Enums\DialogType;

DialogType::SEARCH;
DialogType::STORE;
DialogType::RESULT;
DialogType::INDEX;
DialogType::LIST;
DialogType::FOLDERS;
```

#### DocuWareFieldTypeEnum

Represents different field types used in DocuWare document indexing:

```php
use CodebarAg\DocuWare\Enums\DocuWareFieldTypeEnum;

DocuWareFieldTypeEnum::STRING;
DocuWareFieldTypeEnum::INT;
DocuWareFieldTypeEnum::DECIMAL;
DocuWareFieldTypeEnum::DATE;
DocuWareFieldTypeEnum::DATETIME;
DocuWareFieldTypeEnum::TABLE;
```

### Available Requests

The following sections provide examples for each available request type. All functionality is documented inline below with code examples.
Expand Down
10 changes: 7 additions & 3 deletions src/DTO/General/UserManagement/GetUsers/OutOfOffice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ public static function fromJson(array $data): self
{
if ($startDateTime = Arr::get($data, 'StartDateTime')) {
$startDateTime = Str::of($startDateTime)->after('(')->before(')');
$startDateTime = Carbon::createFromTimestamp($startDateTime);
// Extract milliseconds part (ignore optional timezone offset like +0000)
$milliseconds = (int) (string) $startDateTime;
$startDateTime = Carbon::createFromTimestampMs($milliseconds, 'UTC');
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the timezone of the parsed dates to UTC (previously it used the default timezone). If this behavior is intentional, please document it in the method's docblock or relevant README section to make the UTC normalization explicit.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so would you reocment to take app timezone?

}

if ($endDateTime = Arr::get($data, 'EndDateTime')) {
$endDateTime = Str::of($endDateTime)->after('(')->before(')');
$endDateTime = Carbon::createFromTimestamp($endDateTime);
// Extract milliseconds part (ignore optional timezone offset like +0000)
$milliseconds = (int) (string) $endDateTime;
$endDateTime = Carbon::createFromTimestampMs($milliseconds, 'UTC');
}

return new self(
isOutOfOffice: Arr::get($data, 'IsOutOfOffice'),
startDateTime: $startDateTime,
startDateTimeSpecified: Arr::get($data, 'StartDateTimeSpecified'),
endDateTime: $endDateTime,
endDateTimeSpecified: Arr::get($data, 'EndDateTimeSpecified'),
endDateTimeSpecified: Arr::get($data, key: 'EndDateTimeSpecified'),
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using named arguments with vendor helpers (Arr::get) because parameter names are not part of the public API and can change in framework updates. For consistency with surrounding code and to prevent fragility, use positional arguments: Arr::get($data, 'EndDateTimeSpecified').

Suggested change
endDateTimeSpecified: Arr::get($data, key: 'EndDateTimeSpecified'),
endDateTimeSpecified: Arr::get($data, 'EndDateTimeSpecified'),

Copilot uses AI. Check for mistakes.
);
}

Expand Down
13 changes: 13 additions & 0 deletions src/Enums/DocuWareFieldTypeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CodebarAg\DocuWare\Enums;

enum DocuWareFieldTypeEnum: string
{
case STRING = 'String';
case INT = 'Int';
case DECIMAL = 'Decimal';
case DATE = 'Date';
case DATETIME = 'DateTime';
case TABLE = 'Table';
}
37 changes: 37 additions & 0 deletions tests/Unit/Enums/ConnectionEnumTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use CodebarAg\DocuWare\Enums\ConnectionEnum;

it('has all expected connection enum cases', function () {
$expectedCases = [
'WITHOUT_COOKIE',
'STATIC_COOKIE',
'DYNAMIC_COOKIE',
];

$actualCases = array_map(fn ($case) => $case->value, ConnectionEnum::cases());

expect($actualCases)->toBe($expectedCases);
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asserting exact order of enum cases can make the test brittle if declaration order changes. Consider comparing without order sensitivity (e.g., sort or use toEqualCanonicalizing) unless order is a required part of the API.

Suggested change
expect($actualCases)->toBe($expectedCases);
expect($actualCases)->toEqualCanonicalizing($expectedCases);

Copilot uses AI. Check for mistakes.
});

it('can get string value from enum', function () {
expect(ConnectionEnum::WITHOUT_COOKIE->value)->toBe('WITHOUT_COOKIE');
expect(ConnectionEnum::STATIC_COOKIE->value)->toBe('STATIC_COOKIE');
expect(ConnectionEnum::DYNAMIC_COOKIE->value)->toBe('DYNAMIC_COOKIE');
});

it('can create enum from string value', function () {
expect(ConnectionEnum::from('WITHOUT_COOKIE'))->toBe(ConnectionEnum::WITHOUT_COOKIE);
expect(ConnectionEnum::from('STATIC_COOKIE'))->toBe(ConnectionEnum::STATIC_COOKIE);
expect(ConnectionEnum::from('DYNAMIC_COOKIE'))->toBe(ConnectionEnum::DYNAMIC_COOKIE);
});

it('throws exception for invalid enum value', function () {
expect(fn () => ConnectionEnum::from('INVALID_VALUE'))
->toThrow(ValueError::class);
});

it('can try to create enum from string value', function () {
expect(ConnectionEnum::tryFrom('WITHOUT_COOKIE'))->toBe(ConnectionEnum::WITHOUT_COOKIE);
expect(ConnectionEnum::tryFrom('INVALID_VALUE'))->toBeNull();
});
Loading
Loading