Skip to content

Commit b2794f8

Browse files
makowskidclaude
andcommitted
Initial release - Profanity Detector API client
PHP client for SharpAPI Profanity Detector endpoint. Detects profanities and inappropriate language in text using AI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit b2794f8

6 files changed

Lines changed: 251 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/vendor/
2+
composer.lock
3+
.idea
4+
.DS_Store
5+
node_modules/
6+
npm-debug.log
7+
yarn-error.log
8+
coverage
9+
.phpunit.result.cache

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
All notable changes to `sharpapi/php-content-profanity-detector` will be documented in this file.
4+
5+
## 1.0.0 - 2026-02-22
6+
- Initial release

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 A2Z WEB LTD
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
![SharpAPI GitHub cover](https://sharpapi.com/sharpapi-github-laravel-bg.jpg "SharpAPI PHP Client")
2+
3+
# Content Profanity Detector API for PHP
4+
5+
## 📝 Detect profanities in text using AI - identifies inappropriate language
6+
7+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/sharpapi/php-content-profanity-detector.svg?style=flat-square)](https://packagist.org/packages/sharpapi/php-content-profanity-detector)
8+
[![Total Downloads](https://img.shields.io/packagist/dt/sharpapi/php-content-profanity-detector.svg?style=flat-square)](https://packagist.org/packages/sharpapi/php-content-profanity-detector)
9+
10+
Check the full documentation on the [Content Profanity Detector API for PHP API](https://sharpapi.com/en/catalog/ai/content-marketing-automation/profanity-detector) page.
11+
12+
---
13+
14+
## Quick Links
15+
16+
| Resource | Link |
17+
|----------|------|
18+
| **Main API Documentation** | [Authorization, Webhooks, Polling & More](https://sharpapi.com/documentation) |
19+
| **Product Details** | [SharpAPI.com](https://sharpapi.com/en/catalog/ai/content-marketing-automation/profanity-detector) |
20+
| **SDK Libraries** | [GitHub - SharpAPI SDKs](https://github.com/sharpapi) |
21+
22+
---
23+
24+
## Requirements
25+
26+
- PHP >= 8.0
27+
28+
---
29+
30+
## Installation
31+
32+
### Step 1. Install the package via Composer:
33+
34+
```bash
35+
composer require sharpapi/php-content-profanity-detector
36+
```
37+
38+
### Step 2. Visit [SharpAPI](https://sharpapi.com/) to get your API key.
39+
40+
---
41+
## Laravel Integration
42+
43+
Building a Laravel application? Check the Laravel package version for better integration.
44+
45+
---
46+
47+
## What it does
48+
49+
Detect profanities in text using AI - identifies inappropriate language
50+
51+
---
52+
53+
## Usage
54+
```php
55+
<?php
56+
57+
require __DIR__ . '/vendor/autoload.php';
58+
59+
use SharpAPI\ContentProfanity\ProfanityDetectorClient;
60+
use GuzzleHttp\Exception\GuzzleException;
61+
62+
$apiKey = 'your_api_key_here';
63+
$client = new ProfanityDetectorClient(apiKey: $apiKey);
64+
65+
try {
66+
$statusUrl = $client->detectProfanities(
67+
content: 'Your text content here'
68+
);
69+
70+
// Optional: Configure polling
71+
$client->setApiJobStatusPollingInterval(10);
72+
$client->setApiJobStatusPollingWait(180);
73+
74+
// Fetch results (polls automatically)
75+
$result = $client->fetchResults($statusUrl);
76+
$resultData = $result->getResultJson();
77+
78+
echo $resultData;
79+
} catch (GuzzleException $e) {
80+
echo "API error: " . $e->getMessage();
81+
}
82+
```
83+
84+
---
85+
86+
## Example Response
87+
```json
88+
89+
{
90+
"data": {
91+
"type": "api_job_result",
92+
"id": "06f4a1ba-b6b1-48b3-b071-807e3d41db4d",
93+
"attributes": {
94+
"status": "success",
95+
"type": "content_detect_profanities",
96+
"result": []
97+
}
98+
}
99+
}
100+
101+
```
102+
---
103+
104+
## Changelog
105+
106+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
107+
108+
---
109+
110+
## Credits
111+
112+
- [A2Z WEB LTD](https://github.com/a2zwebltd)
113+
- [Dawid Makowski](https://github.com/makowskid)
114+
- Boost your [PHP AI](https://sharpapi.com/) capabilities!
115+
116+
---
117+
118+
## License
119+
120+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.md)
121+
122+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
123+
124+
---
125+
126+
## Social Media
127+
128+
🚀 For the latest news, tutorials, and case studies, don't forget to follow us on:
129+
- [SharpAPI X (formerly Twitter)](https://x.com/SharpAPI)
130+
- [SharpAPI YouTube](https://www.youtube.com/@SharpAPI)
131+
- [SharpAPI Vimeo](https://vimeo.com/SharpAPI)
132+
- [SharpAPI LinkedIn](https://www.linkedin.com/products/a2z-web-ltd-sharpapicom-automate-with-aipowered-api/)
133+
- [SharpAPI Facebook](https://www.facebook.com/profile.php?id=61554115896974)

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "sharpapi/php-content-profanity-detector",
3+
"description": "Detect profanities in text using AI - identifies inappropriate language",
4+
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"sharpapi",
8+
"content-marketing",
9+
"php",
10+
"ai",
11+
"api",
12+
"content",
13+
"profanity",
14+
"moderation"
15+
],
16+
"homepage": "https://sharpapi.com/",
17+
"authors": [
18+
{
19+
"name": "A2Z WEB LTD",
20+
"homepage": "https://sharpapi.com/"
21+
}
22+
],
23+
"require": {
24+
"php": ">=8.0",
25+
"sharpapi/php-core": "^1.4.0",
26+
"guzzlehttp/guzzle": "^7.0|^7.9|^7.10"
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"SharpAPI\\ContentProfanity\\": "src/"
31+
}
32+
},
33+
"minimum-stability": "dev",
34+
"prefer-stable": true,
35+
"support": {
36+
"source": "https://github.com/sharpapi/php-content-profanity-detector",
37+
"issues": "https://github.com/sharpapi/php-content-profanity-detector/issues"
38+
}
39+
}

src/ProfanityDetectorClient.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SharpAPI\ContentProfanity;
6+
7+
use GuzzleHttp\Exception\GuzzleException;
8+
use SharpAPI\Core\Client\SharpApiClient;
9+
10+
/**
11+
* Detect profanities in text using AI - identifies inappropriate language
12+
*
13+
* @package SharpAPI\ContentProfanity
14+
* @api
15+
*/
16+
class ProfanityDetectorClient extends SharpApiClient
17+
{
18+
public function __construct(
19+
string $apiKey,
20+
?string $apiBaseUrl = 'https://sharpapi.com/api/v1',
21+
?string $userAgent = 'SharpAPIPHPContentProfanity/1.0.0'
22+
) {
23+
parent::__construct($apiKey, $apiBaseUrl, $userAgent);
24+
}
25+
26+
/**
27+
* Detect profanities in text using AI - identifies inappropriate language
28+
*
29+
* @param string $content The text content to process
30+
* @return string Status URL for polling the job result
31+
* @throws GuzzleException
32+
* @api
33+
*/
34+
public function detectProfanities(
35+
string $content
36+
): string {
37+
$response = $this->makeRequest('POST', '/content/detect_profanities', array_filter([
38+
'content' => $content
39+
], fn($v) => $v !== null));
40+
41+
return $this->parseStatusUrl($response);
42+
}
43+
}

0 commit comments

Comments
 (0)