Skip to content

Commit 835fa0d

Browse files
committed
feat: Vocative implementation
1 parent 5b95263 commit 835fa0d

File tree

14 files changed

+1449
-0
lines changed

14 files changed

+1449
-0
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.php]
14+
indent_size = 4
15+
16+
[phpcs.xml]
17+
indent_size = 4

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/.github export-ignore
2+
/.codeclimate.yml export-ignore
3+
/.editorconfig export-ignore
4+
/.gitattributes export-ignore
5+
/.gitignore export-ignore
6+
/.releaserc export-ignore
7+
/CODE_OF_CONDUCT.md export-ignore
8+
/composer.lock export-ignore
9+
/CONTRIBUTING.md export-ignore
10+
/docs export-ignore
11+
/examples export-ignore
12+
/SECURITY.md export-ignore
13+
/phpcs.xml export-ignore
14+
/phpstan.neon export-ignore
15+
/phpunit.xml export-ignore

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
- alpha
8+
- beta
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
token: ${{ secrets.OBLAKBOT_PAT }}
20+
- name: Import GPG key
21+
uses: crazy-max/ghaction-import-gpg@v6
22+
id: gpg
23+
with:
24+
gpg_private_key: ${{ secrets.OBLAKBOT_GPG_KEY }}
25+
passphrase: ${{ secrets.OBLAKBOT_GPG_PASS }}
26+
git_config_global: true
27+
git_user_signingkey: true
28+
git_commit_gpgsign: true
29+
- name: Semantic Release
30+
uses: cycjimmy/semantic-release-action@v4
31+
with:
32+
extra_plugins: |
33+
@semantic-release/github
34+
@semantic-release/exec
35+
env:
36+
GIT_AUTHOR_NAME: ${{ steps.gpg.outputs.name}}
37+
GIT_AUTHOR_EMAIL: ${{ steps.gpg.outputs.email}}
38+
GIT_COMMITTER_NAME: ${{ steps.gpg.outputs.name}}
39+
GIT_COMMITTER_EMAIL: ${{ steps.gpg.outputs.email}}
40+
GITHUB_TOKEN: ${{ secrets.OBLAKBOT_PAT }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
test.php

.phpcs.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Oblak Composer library Ruleset">
3+
<config name="testVersion" value="8.0-"/>
4+
5+
<rule ref="PHPCompatibility"/>
6+
<rule ref="Oblak-Slevomat"/>
7+
<rule ref="PSR12"/>
8+
9+
<file>src/</file>
10+
11+
</ruleset>

.releaserc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"branches": [
3+
"master",
4+
{
5+
"name": "develop",
6+
"prerelease": true
7+
},
8+
{
9+
"name": "alpha",
10+
"prerelease": true
11+
},
12+
{
13+
"name": "beta",
14+
"prerelease": true
15+
}
16+
],
17+
"plugins": [
18+
"@semantic-release/commit-analyzer",
19+
"@semantic-release/release-notes-generator",
20+
[
21+
"@semantic-release/exec",
22+
{
23+
"prepareCmd": "zip -r '/tmp/release.zip' ./src README.md ./composer.json"
24+
}
25+
],
26+
[
27+
"@semantic-release/github",
28+
{
29+
"assets": [
30+
{
31+
"path": "/tmp/release.zip",
32+
"name": "vocative-v${nextRelease.version}.zip",
33+
"label": "Vocative v${nextRelease.version}"
34+
}
35+
]
36+
}
37+
]
38+
]
39+
}

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@woocommerce.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
bootstrapFiles:
6+
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
7+
scanFiles:
8+
- stubs/const.php
9+
- vendor/wp-cli/wp-cli/php/utils.php
10+
ignoreErrors:
11+

src/BaseDictionary.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Oblak\Vocative;
4+
5+
use Oblak\Vocative\Interfaces\Dictionary;
6+
use Stringable;
7+
8+
class BaseDictionary implements Dictionary
9+
{
10+
/**
11+
* Dictionary of exceptions
12+
*
13+
* @var array<string,string>
14+
*/
15+
private array $names = [
16+
'ALEKSA' => 'ALEKSA',
17+
'ALEKSANDAR' => 'ALEKSANDRE',
18+
'ANKA' => 'ANKA',
19+
'BLAŽA' => 'BLAŽO',
20+
'CANA' => 'CANO',
21+
'CVETA' => 'CVETO',
22+
'GROZDA' => 'GROZDA',
23+
'IVKA' => 'IVKA',
24+
'JANA' => 'JANO',
25+
'JELA' => 'JELO',
26+
'JEVTA' => 'JEVTO',
27+
'KRSTA' => 'KRSTO',
28+
'LARA' => 'LARA',
29+
'LAZA' => 'LAZO',
30+
'LOLA' => 'LOLO',
31+
'LUKA' => 'LUKA',
32+
'MATA' => 'MATO',
33+
'MATEJ' => 'MATEJ',
34+
'MELISA' => 'MELISA',
35+
'MICA' => 'MICO',
36+
'MILESA' => 'MILESA',
37+
'MIĆA' => 'MIĆO',
38+
'MOŠA' => 'MOŠO',
39+
'NATA' => 'NATO',
40+
'OLJA' => 'OLJA',
41+
'OSTOJA' => 'OSTOJA',
42+
'RATAR' => 'RATARE',
43+
'RELJA' => 'RELJA',
44+
'SIMA' => 'SIMO',
45+
'SLAĐAN' => 'SLAĐAN',
46+
'STANA' => 'STANO',
47+
'STAVRA' => 'STAVRO',
48+
'TOMA' => 'TOMO',
49+
'TOŠA' => 'TOŠO',
50+
'VERA' => 'VERA',
51+
'ZLATA' => 'ZLATO',
52+
'ŠANA' => 'ŠANO',
53+
];
54+
55+
public function hasName(string|Stringable $name): bool
56+
{
57+
return isset($this->names[(string)$name]);
58+
}
59+
60+
public function getName(string|Stringable $name): string
61+
{
62+
return $this->names[(string)$name];
63+
}
64+
}

src/Interfaces/Dictionary.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Oblak\Vocative\Interfaces;
4+
5+
use Stringable;
6+
7+
interface Dictionary
8+
{
9+
/**
10+
* Check if a name is in the dictionary
11+
*
12+
* @param string|Stringable $name Name in nominative case
13+
* @return bool
14+
*/
15+
public function hasName(string|Stringable $name): bool;
16+
17+
/**
18+
* Get the vocative case form of a name
19+
*
20+
* @param string|Stringable $name Name in nominative case
21+
* @return string
22+
*/
23+
public function getName(string|Stringable $name): string;
24+
}

0 commit comments

Comments
 (0)