Skip to content

Commit d7ad1d6

Browse files
committed
Implemented DSN Connection Strings Support
This PR introduces support for DSN connection strings to simplify the configuration process. Users can now use a single string to determine the type of connection (`Network` or `Pipe`) and its details. This PR resolves #28, closes #25, resolves #26, closes #27, closes #31 1. Added a static `createFromDSN` method to the `ClamAV` abstract class. This method parses the provided DSN string and returns an appropriate instance (`Network` or `Pipe`). 2. Updated the `ClamAVTest` unit test to cover the new DSN creation functionality. 3. Updated composer dependencies 4. Applied smaller code, and documentation optimizations 5. Improved code coverage 6. Updated README Users can now initialize a connection using a DSN string: ```php $clam = ClamAV::createFromDSN('tcp://localhost:3310'); $version = $clam->version(); ``` This approach provides a more flexible and user-friendly way to set up a connection. The existing unit tests have been updated accordingly.
1 parent f5f0078 commit d7ad1d6

File tree

11 files changed

+553
-443
lines changed

11 files changed

+553
-443
lines changed

.php-cs-fixer.dist.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->exclude('*/vendor/*')
4+
->exclude('node_modules')
5+
->in(__DIR__)
6+
->notPath('lib/system/api');
7+
8+
return (new PhpCsFixer\Config())
9+
->setRiskyAllowed(true)
10+
->setRules([
11+
'@PSR1' => true,
12+
'@PSR2' => true,
13+
'@PSR12' => true,
14+
'@PER' => true,
15+
16+
'array_push' => true,
17+
'backtick_to_shell_exec' => true,
18+
'no_alias_language_construct_call' => true,
19+
'no_mixed_echo_print' => true,
20+
'pow_to_exponentiation' => true,
21+
'random_api_migration' => true,
22+
23+
'array_syntax' => ['syntax' => 'short'],
24+
'no_multiline_whitespace_around_double_arrow' => true,
25+
'no_trailing_comma_in_singleline_array' => true,
26+
'no_whitespace_before_comma_in_array' => true,
27+
'normalize_index_brace' => true,
28+
'whitespace_after_comma_in_array' => true,
29+
30+
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
31+
32+
'magic_constant_casing' => true,
33+
'magic_method_casing' => true,
34+
'native_function_casing' => true,
35+
'native_function_type_declaration_casing' => true,
36+
37+
'cast_spaces' => ['space' => 'none'],
38+
'no_unset_cast' => true,
39+
40+
'class_attributes_separation' => true,
41+
'no_null_property_initialization' => true,
42+
'self_accessor' => true,
43+
'single_class_element_per_statement' => true,
44+
45+
'no_empty_comment' => true,
46+
'single_line_comment_style' => ['comment_types' => ['hash']],
47+
48+
'native_constant_invocation' => ['strict' => false],
49+
50+
'no_alternative_syntax' => true,
51+
'no_trailing_comma_in_list_call' => true,
52+
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from']],
53+
'no_unneeded_curly_braces' => ['namespaces' => true],
54+
'switch_continue_to_break' => true,
55+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
56+
57+
'function_typehint_space' => true,
58+
'lambda_not_used_import' => true,
59+
'native_function_invocation' => ['include' => ['@internal']],
60+
'no_unreachable_default_argument_value' => true,
61+
'nullable_type_declaration_for_default_null_value' => true,
62+
'static_lambda' => true,
63+
64+
'fully_qualified_strict_types' => true,
65+
'no_unused_imports' => true,
66+
67+
'dir_constant' => true,
68+
'explicit_indirect_variable' => true,
69+
'function_to_constant' => true,
70+
'is_null' => true,
71+
'no_unset_on_property' => true,
72+
73+
'list_syntax' => ['syntax' => 'short'],
74+
75+
'clean_namespace' => true,
76+
'no_leading_namespace_whitespace' => true,
77+
78+
'no_homoglyph_names' => true,
79+
80+
'binary_operator_spaces' => true,
81+
'concat_space' => ['spacing' => 'one'],
82+
'increment_style' => ['style' => 'post'],
83+
'logical_operators' => true,
84+
'object_operator_without_whitespace' => true,
85+
'operator_linebreak' => true,
86+
'standardize_increment' => true,
87+
'standardize_not_equals' => true,
88+
'ternary_to_elvis_operator' => true,
89+
'ternary_to_null_coalescing' => true,
90+
'unary_operator_spaces' => true,
91+
92+
'no_useless_return' => true,
93+
'return_assignment' => true,
94+
95+
'multiline_whitespace_before_semicolons' => true,
96+
'no_empty_statement' => true,
97+
'no_singleline_whitespace_before_semicolons' => true,
98+
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
99+
100+
'escape_implicit_backslashes' => true,
101+
'explicit_string_variable' => true,
102+
'heredoc_to_nowdoc' => true,
103+
'no_binary_string' => true,
104+
'simple_to_complex_string_variable' => true,
105+
106+
'array_indentation' => true,
107+
'blank_line_before_statement' => ['statements' => ['return', 'exit']],
108+
'method_chaining_indentation' => true,
109+
'no_extra_blank_lines' => ['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use']],
110+
'no_spaces_around_offset' => true,
111+
112+
// SoftCreatR style
113+
'global_namespace_import' => [
114+
'import_classes' => true,
115+
'import_constants' => true,
116+
'import_functions' => false,
117+
],
118+
'ordered_imports' => [
119+
'imports_order' => ['class', 'function', 'const'],
120+
],
121+
])
122+
->setFinder($finder);

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
dist: focal
1+
dist: jammy
22

33
language: php
44

55
php:
6-
- 8.0
76
- 8.1
87

98
notifications:

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ Install using composer:
1414
composer require appwrite/php-clamav
1515
```
1616

17+
Example usage:
1718
```php
1819
<?php
1920

2021
require_once 'vendor/autoload.php';
2122

22-
use Appwrite\ClamAV\Network;
23+
use Appwrite\ClamAV\ClamAV;
2324

24-
$clam = new Network('localhost', 3310); // Or use new Pipe() for unix socket
25+
$clam = ClamAV::createFromDSN('tcp://localhost:3310');
2526

2627
$clam->ping(); // Check ClamAV is up and running
2728

@@ -36,7 +37,7 @@ $clam->shutdown(); // Shutdown ClamAV
3637

3738
## System Requirements
3839

39-
This package requires PHP 7.1 or later. We recommend using the latest PHP version whenever possible.
40+
This package requires PHP 8.1 or later. We recommend using the latest PHP version whenever possible.
4041

4142
## Find Us
4243

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"ext-sockets": "*"
3131
},
3232
"require-dev": {
33-
"phpunit/phpunit": "^9"
33+
"phpunit/phpunit": ">=9"
3434
},
3535
"minimum-stability": "stable"
3636
}

0 commit comments

Comments
 (0)