Skip to content

Commit

Permalink
build(idna translator): added dependabot, semantic release, composer …
Browse files Browse the repository at this point in the history
…and gulp integration
  • Loading branch information
AsifNawaz-cnic committed Mar 21, 2024
1 parent 733eceb commit 801b790
Show file tree
Hide file tree
Showing 14 changed files with 11,120 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
#PHP PROJECT
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "fix"
prefix-development: "chore"
include: "scope"
11 changes: 11 additions & 0 deletions .github/linters/phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>

<ruleset name="super-linter">
<description>The default coding standard for usage with GitHub Super-Linter. It just includes PSR12.</description>
<!-- Use PSR-12 as a base -->
<rule ref="PSR12"/>
<arg value="s"/>
<arg value="q"/>
<arg value="n"/>
<arg name="colors"/>
</ruleset>
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
uses: centralnicgroup-opensource/rtldev-middleware-shareable-workflows/.github/workflows/release.yml@main
secrets: inherit
with:
repository: ${{ github.repository }}
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Dependabot auto-merge & tests
on:
pull_request:
types:
- opened
- synchronize

jobs:
tests:
uses: centralnicgroup-opensource/rtldev-middleware-shareable-workflows/.github/workflows/auto-merge-dependabot-pr.yml@main
secrets: inherit
with:
repository: ${{ github.repository }}
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
vendor
/tests/logs/*.txt
/tests/logs/*.log
basic-test.php
vendor
report
docs
node_modules
composer.lock
.phpunit.result.cache
31 changes: 31 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "HISTORY.md"
}
],
[
"@semantic-release/exec",
{
"successCmd": "gulp publishNotification --update \"${nextRelease.version}\" --type \"${nextRelease.type}\" --notes \"${encodeURIComponent(nextRelease.notes)}\""
}
],
[
"@semantic-release/git",
{
"assets": [
"HISTORY.md",
"@(package?(-lock)|composer).json",
"docs",
"report",
"src"
]
}
],
"@semantic-release/github"
]
}
Empty file added HISTORY.md
Empty file.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ConverterFactory

The `ConverterFactory` class provides functionality for converting domain strings between Unicode and Punycode formats.

## Use Cases

- **Domain Conversion**: Convert domain strings between Unicode and Punycode formats to ensure compatibility and consistency across different systems.

## Usage

### 1. Convert a Domain String to Unicode

```php
<?php

use CNIC\IDNA\Factory\ConverterFactory;

// Convert a domain string to Unicode format
$domain = "example.com";
$unicodeDomain = ConverterFactory::toUnicode($domain);
echo "Unicode Domain: $unicodeDomain\n";
```

### 2. Convert a Domain String to Punycode

```php
<?php

use CNIC\IDNA\Factory\ConverterFactory;

// Convert a domain string to Punycode format
$unicodeDomain = "example.com";
$punycodeDomain = ConverterFactory::toASCII($unicodeDomain);
echo "Punycode Domain: $
```

### 3. Convert Multiple Domain Strings

```php
<?php

use CNIC\IDNA\Factory\ConverterFactory;

// Convert multiple domain strings to Unicode and Punycode formats
$domains = ["example.com", "münchen.de", "рф.ru"];
$convertedDomains = ConverterFactory::convert($domains);
foreach ($convertedDomains as $domain) {
echo "Unicode Domain: {$domain['IDN']}, Punycode Domain: {$domain['PUNYCODE']}\n";
}
```

## API Documentation

```php
### `ConverterFactory::toUnicode($keyword, $options = [])`

Converts a domain string to Unicode format.

- **Parameters:**
- `$keyword` (string): The domain string to convert.
- `$options` (array): Additional options for the conversion process (optional).
- **Returns:** The converted domain in Unicode format, or `false` if the keyword is empty.

### `ConverterFactory::toASCII($keyword, $options = [])`

Converts a domain string to Punycode format.

- **Parameters:**
- `$keyword` (string): The domain string to convert.
- `$options` (array): Additional options for the conversion process (optional).
- **Returns:** The converted domain in Punycode format, or `false` if the keyword is empty.
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"type": "library",
"license": "MIT",
"require-dev": {
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.9"
},
"autoload": {
"psr-4": {
"CNIC\\IDNA\\": "lib/"
"CNIC\\IDNA\\": "src/IDNA/"
}
},
"autoload-dev": {
Expand All @@ -17,7 +18,9 @@
}
},
"scripts": {
"test": "phpunit --verbose tests/IDNATranslatorTest.php"
"codefix": "phpcbf --ignore=\"*/vendor/*\" --standard=PSR12 -q src tests",
"codecheck": "phpcs --ignore=\"*/vendor/*\" --standard=PSR12 -q src tests",
"test": "XDEBUG_MODE=coverage phpunit --coverage-html=./reports/html"
},
"config": {
"sort-packages": true
Expand Down
82 changes: 81 additions & 1 deletion composer.lock

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

1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.publishNotification = require('rtldev-middleware-gulp-release-notification-plugin');
Loading

0 comments on commit 801b790

Please sign in to comment.