Skip to content

Commit

Permalink
Add PHP types
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary authored Jan 6, 2025
1 parent 05f2248 commit cbea5ba
Show file tree
Hide file tree
Showing 138 changed files with 1,993 additions and 2,560 deletions.
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: 1
paths:
- src
ignoreErrors:
- '#Unsafe usage of new static\(\)#'
4 changes: 2 additions & 2 deletions src/Api/Admin/AdminApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class AdminApi
/**
* AdminApi constructor.
*
* @param mixed $configuration
* @param mixed|null $configuration
*
* @noinspection UnusedConstructorDependenciesInspection*/
public function __construct($configuration = null)
public function __construct(mixed $configuration = null)
{
$this->apiClient = new ApiClient($configuration);

Expand Down
35 changes: 20 additions & 15 deletions src/Api/Admin/AnalysisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,42 @@ trait AnalysisTrait
/**
* Analyzes an asset with the requested analysis type.
*
* @param string $inputType The type of input for the asset to analyze ('uri').
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
* @param string $uri The URI of the asset to analyze.
* @param array $parameters Additional parameters.
* @param string $inputType The type of input for the asset to analyze ('uri').
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
* @param string|null $uri The URI of the asset to analyze.
* @param array|null $parameters Additional parameters.
*
*
* @return ApiResponse
*
* @see AdminApi::analyzeAsync()
*
* @see https://cloudinary.com/documentation/media_analyzer_api_reference
*/
public function analyze($inputType, $analysisType, $uri = null, $parameters = null)
{
public function analyze(
string $inputType,
string $analysisType,
?string $uri = null,
?array $parameters = null
): ApiResponse {
return $this->analyzeAsync($inputType, $analysisType, $uri, $parameters)->wait();
}

/**
* Analyzes an asset with the requested analysis type asynchronously.
*
* @param string $inputType The type of input for the asset to analyze ('uri').
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
* @param string $uri The URI of the asset to analyze.
* @param array $parameters Additional parameters.
*
* @return PromiseInterface
* @param string $inputType The type of input for the asset to analyze ('uri').
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
* @param string|null $uri The URI of the asset to analyze.
* @param array|null $parameters Additional parameters.
*
* @see https://cloudinary.com/documentation/media_analyzer_api_reference
*/
public function analyzeAsync($inputType, $analysisType, $uri = null, $parameters = null)
{
public function analyzeAsync(
string $inputType,
string $analysisType,
?string $uri = null,
?array $parameters = null
): PromiseInterface {
$endPoint = [ApiEndPoint::ANALYSIS, 'analyze', $inputType];

$params = ['analysis_type' => $analysisType, 'uri' => $uri, 'parameters' => $parameters];
Expand Down
28 changes: 14 additions & 14 deletions src/Api/Admin/ApiEndPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
class ApiEndPoint
{
const PING = 'ping';
const CONFIG = 'config';
const USAGE = 'usage';
const ASSETS = 'resources';
const DERIVED_ASSETS = 'derived_resources';
const RELATED_ASSETS = 'related_assets';
const FOLDERS = 'folders';
const TAGS = 'tags';
const STREAMING_PROFILES = 'streaming_profiles';
const TRANSFORMATIONS = 'transformations';
const UPLOAD_PRESETS = 'upload_presets';
const UPLOAD_MAPPINGS = 'upload_mappings';
const METADATA_FIELDS = 'metadata_fields';
const ANALYSIS = 'analysis';
public const PING = 'ping';
public const CONFIG = 'config';
public const USAGE = 'usage';
public const ASSETS = 'resources';
public const DERIVED_ASSETS = 'derived_resources';
public const RELATED_ASSETS = 'related_assets';
public const FOLDERS = 'folders';
public const TAGS = 'tags';
public const STREAMING_PROFILES = 'streaming_profiles';
public const TRANSFORMATIONS = 'transformations';
public const UPLOAD_PRESETS = 'upload_presets';
public const UPLOAD_MAPPINGS = 'upload_mappings';
public const METADATA_FIELDS = 'metadata_fields';
public const ANALYSIS = 'analysis';
}
Loading

0 comments on commit cbea5ba

Please sign in to comment.