valksor / php-functions-latvian
A PHP library providing functions specific to Latvian language and data formats, including Latvian text comparison, sorting according to Latvian alphabet rules, and validation of Latvian personal identification codes
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/valksor/php-functions-latvian
Requires
- php: >=8.4
- valksor/php-functions-date: ^1.0
- valksor/php-functions-iteration: ^1.0
- valksor/php-functions-text: ^1.0
This package is auto-updated.
Last update: 2025-10-29 19:31:54 UTC
README
A PHP library providing functions specific to Latvian language and data formats, including Latvian text comparison, sorting according to Latvian alphabet rules, and validation of Latvian personal identification codes.
Installation
Install the package via Composer:
composer require valksor/php-functions-latvian
Requirements
PHP 8.4 or higher
Usage
There are two ways to use this package: via the Functions class or by directly using the traits.
Using the Functions Class
The Functions class provides utilities for working with Latvian-specific data and text.
use Valksor\Functions\Latvian\Functions; // Create a new Functions instance $functions = new Functions(); // Validate a Latvian personal identification code $isValid = $functions->validatePersonCode('32XXXXXXXXX'); // For new format $isValid = $functions->validatePersonCode('XXXXXXXXXXX'); // For old format // Sort an array of names according to Latvian alphabet rules $names = [ ['name' => 'Ēriks'], ['name' => 'Andris'], ['name' => 'Čalis'], ['name' => 'Zane'], ]; $functions->sortLatvian($names, 'name'); // Result: Andris, Čalis, Ēriks, Zane // Compare two strings using Latvian alphabet rules $result = $functions->compare(['name' => 'Ēriks'], ['name' => 'Andris'], 'name'); // Result: positive integer (Ēriks comes after Andris in Latvian alphabet)
Using Traits Directly
Alternatively, you can use the traits directly in your own classes:
use Valksor\Functions\Latvian\Traits\_Compare; use Valksor\Functions\Latvian\Traits\_SortLatvian; use Valksor\Functions\Latvian\Traits\_ValidatePersonCode; class MyClass { // Import the traits you need use _Compare; use _SortLatvian; use _ValidatePersonCode; public function doSomething(): void { // Validate a Latvian personal identification code $isValid = $this->validatePersonCode('32XXXXXXXXX'); // Sort an array of names according to Latvian alphabet rules $names = [ ['name' => 'Ēriks'], ['name' => 'Andris'], ['name' => 'Čalis'], ['name' => 'Zane'], ]; $this->sortLatvian($names, 'name'); // Compare two strings using Latvian alphabet rules $result = $this->compare(['name' => 'Ēriks'], ['name' => 'Andris'], 'name'); } }
Note that some traits may depend on other helper traits. For example, the _ValidatePersonCode trait uses _ValidatePersonCodeNew and _ValidatePersonCodeOld internally. The Functions class handles these dependencies for you, but if you use the traits directly, you may need to include these helper traits as well.
Features
For a complete list of all functions available in this package, see Features.
Contributing
Contributions are welcome! Please read our Contributing Guidelines for details on:
- Code style requirements (PSR-12)
- Testing requirements for PRs
- One feature per pull request
- Development setup instructions
To contribute to Latvian functions:
- Fork the repository
- Create a feature branch (git checkout -b feature/new-latvian-function)
- Implement your function following existing patterns
- Add comprehensive tests including edge cases
- Ensure all tests pass and code style is correct
- Submit a pull request
Security
If you discover any security-related issues, please email us at security@valksor.dev instead of using the issue tracker.
For security policy and vulnerability reporting guidelines, please see our Security Policy.
Support
- Documentation: Full documentation
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for questions and community support
- Stack Overflow: Use tag valksor-php-functions-latvian
Credits
- Original Author - Creator and maintainer
- All Contributors - Thank you to all who contributed
- Latvian Language Resources - Latvian language standards and inspiration
- Valksor Project - Part of the larger Valksor PHP ecosystem
License
This package is licensed under the BSD-3-Clause License.
About Valksor
This package is part of the valksor/php-valksor project - a comprehensive PHP library and Symfony bundle that provides a collection of utilities, components, and integrations for Symfony applications.
The main project includes:
- Various utility functions and components
- Doctrine ORM tools and extensions
- Symfony bundle for easy configuration
- And much more
If you find this Latvian functions component useful, you might want to check out the full Valksor project for additional tools and utilities that can enhance your Symfony application development.
To install the complete package:
composer require valksor/php-valksor