Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding UserAgent Component #34

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ test-money: phpunit
test-pager: PHPUNIT_TESTSUITE=pager
test-pager: phpunit

test-user-agent: PHPUNIT_TESTSUITE=user-agent
test-user-agent: phpunit

phpunit:
XDEBUG_MODE=$(XDEBUG_MODE) \
$(PHP) \
Expand Down
8 changes: 8 additions & 0 deletions bard.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@
"path": "src/SonsOfPHP/Contract/Pager",
"repository": "[email protected]:SonsOfPHP/pager-contract.git"
},
{
"path": "src/SonsOfPHP/Component/UserAgent",
"repository": "[email protected]:SonsOfPHP/user-agent.git"
},
{
"path": "src/SonsOfPHP/Contract/UserAgent",
"repository": "[email protected]:SonsOfPHP/user-agent-contract.git"
},
{
"path": "src/SonsOfPHP/Contract/Version",
"repository": "[email protected]:SonsOfPHP/version-contract.git"
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
<directory>src/SonsOfPHP/Component/Pager/Tests</directory>
</testsuite>

<!--<testsuite name="user-agent">-->
<!-- <directory>src/SonsOfPHP/Component/UserAgent/Tests</directory>-->
<!--</testsuite>-->

<testsuite name="version">
<directory>src/SonsOfPHP/Component/Version/Tests</directory>
</testsuite>
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
3 changes: 3 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
phpunit.xml
vendor/
19 changes: 19 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2022 Joshua Estes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Sons of PHP - User Agent Component
==================================

## Learn More

* [Documentation][docs]
* [Contributing][contributing]
* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the
[Mother Repository][mother-repo]
* Get Help & Support using [Discussions][discussions] or [Discord][discord]

[discussions]: https://github.com/orgs/SonsOfPHP/discussions
[mother-repo]: https://github.com/SonsOfPHP/sonsofphp
[contributing]: https://docs.sonsofphp.com/contributing/
[docs]: https://docs.sonsofphp.com/components/user-agent/
[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AUserAgent
[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AUserAgent
[discord]: https://discord.gg/sdVxNhFqND
12 changes: 12 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/UserAgentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Component\UserAgent;

/**
* @author Joshua Estes <[email protected]>
*/
class UserAgentException extends \Exception
{
}
52 changes: 52 additions & 0 deletions src/SonsOfPHP/Component/UserAgent/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "sonsofphp/user-agent",
"type": "library",
"description": "Provides more details about the browser the end user is currently using.",
"keywords": [
"user-agent",
"browser"
],
"homepage": "https://github.com/SonsOfPHP/user-agent",
"license": "MIT",
"authors": [
{
"name": "Joshua Estes",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/SonsOfPHP/sonsofphp/issues",
"forum": "https://github.com/orgs/SonsOfPHP/discussions",
"docs": "https://docs.sonsofphp.com",
"chat": "https://discord.gg/sdVxNhFqND"
},
"autoload": {
"psr-4": {
"SonsOfPHP\\Component\\UserAgent\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1"
},
"extra": {
"sort-packages": true,
"branch-alias": {
"dev-main": "0.3.x-dev"
}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/JoshuaEstes"
},
{
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
]
}
2 changes: 2 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.gitattributes export-ignore
/.gitignore export-ignore
2 changes: 2 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composer.lock
vendor/
19 changes: 19 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2022 to Present Joshua Estes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Sons of PHP - User Agent Contract
=================================

## Learn More

* [Documentation][docs]
* [Contributing][contributing]
* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo]
* Get Help & Support using [Discussions][discussions]

[discussions]: https://github.com/orgs/SonsOfPHP/discussions
[mother-repo]: https://github.com/SonsOfPHP/sonsofphp
[contributing]: https://docs.sonsofphp.com/contributing/
[docs]: https://docs.sonsofphp.com/contracts/user-agent/
[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AUserAgent
[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AUserAgent
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\UserAgent;

/**
* @author Joshua Estes <[email protected]>
*/
interface UserAgentExceptionInterface {}
15 changes: 15 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/UserAgentFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\UserAgent;

/**
* @author Joshua Estes <[email protected]>
*/
interface UserAgentFactoryInterface
{
public static function createFromGlobals(): UserAgentInterface;

// createFromRequest(RequestInterface $request); <- PSR-7 Request
}
19 changes: 19 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/UserAgentInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\UserAgent;

/**
* @author Joshua Estes <[email protected]>
*/
interface UserAgentInterface extends \Stringable, \JsonSerializable
{
public function isBot(): bool;

public function isMobile(): bool;

public function isTablet(): bool;

public function isDesktop(): bool;
}
13 changes: 13 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/UserAgentProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Contract\UserAgent;

/**
* @author Joshua Estes <[email protected]>
*/
interface UserAgentProviderInterface
{
public function getForUA(string $ua): UserAgentInterface;
}
52 changes: 52 additions & 0 deletions src/SonsOfPHP/Contract/UserAgent/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "sonsofphp/user-agent-contract",
"type": "library",
"description": "",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"homepage": "https://github.com/SonsOfPHP/user-agent-contract",
"license": "MIT",
"authors": [
{
"name": "Joshua Estes",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/SonsOfPHP/sonsofphp/issues",
"forum": "https://github.com/orgs/SonsOfPHP/discussions",
"docs": "https://docs.sonsofphp.com"
},
"autoload": {
"psr-4": {
"SonsOfPHP\\Contract\\UserAgent\\": ""
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1"
},
"extra": {
"sort-packages": true,
"branch-alias": {
"dev-main": "0.3.x-dev"
}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/JoshuaEstes"
},
{
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
]
}
Loading