Passed
Push — master ( d426ba...3a61d1 )
by Chris
14:30
created

Rekognition::detectFaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Meema\MediaRecognition\Recognizers;
4
5
use Aws\Credentials\Credentials;
6
use Aws\Rekognition\RekognitionClient;
7
use Illuminate\Support\Facades\Storage;
8
use Meema\MediaRecognition\Contracts\MediaRecognition;
9
use Meema\MediaRecognition\Traits\InteractsWithStorage;
10
11
class Rekognition implements MediaRecognition
12
{
13
    use InteractsWithStorage;
14
15
    /**
16
     * Client instance of MediaRecognition.
17
     *
18
     * @var \Aws\Rekognition\RekognitionClient
19
     */
20
    protected RekognitionClient $client;
21
22
    /**
23
     * Construct converter.
24
     *
25
     * @param \Aws\Rekognition\RekognitionClient $client
26
     */
27
    public function __construct(RekognitionClient $client)
28
    {
29
        $this->client = $client;
30
    }
31
32
    /**
33
     * Get the MediaRecognition Client.
34
     *
35
     * @return \Aws\Rekognition\RekognitionClient
36
     */
37
    public function getClient(): RekognitionClient
38
    {
39
        return $this->client;
40
    }
41
42
    /**
43
     * Detects labels/objects in an image.
44
     */
45
    public function detectFaces()
46
    {
47
        return $this->client->detectLabels([
48
            'Image' => [
49
                'S3Object' => [
50
                    'Bucket' => 'meema-stage',
51
                    'Name' => 'test-media/people.jpg',
52
                ],
53
            ],
54
        ]);
55
    }
56
57
    /**
58
     * Detects faces in an image.
59
     */
60
    public function detectFaces()
61
    {
62
        //if ($this->path && $this->disk) {
63
        //    Storage::disk($this->disk)->path($this->path);
64
        //}
65
66
        return $this->client->detectFaces();
67
    }
68
69
    /**
70
     * Detects text in an image (OCR).
71
     */
72
    public function detectText($minConfidence = 50)
73
    {
74
        $bytes = '';
75
76
        $results = $this->client->detectText([
0 ignored issues
show
Unused Code introduced by
The assignment to $results is dead and can be removed.
Loading history...
77
            'Image' => ['Bytes' => $bytes],
78
            'MinConfidence' => $minConfidence,
79
        ])['TextDetections'];
80
    }
81
}
82