• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pgrimaud / instagram-user-feed / 7311167597

23 Dec 2023 11:55PM UTC coverage: 92.348% (-0.2%) from 92.522%
7311167597

push

github

web-flow
Do not hydrate media or IGTV loaded with profile data (#362)

* Mark IMAP client test as skipped when IMAP extension is not loaded

This prevents having the test suite fail on platforms when the extension
is not loaded.  The test is marked as skipped so the developer knows
that the full test suite was not run

* Add a convenience script to run unit tests with "composer test"

* Do not hydrate media or IGTV loaded with profile data

Instagram no longer reliably returns medias or IGTVs with the call to
get profile information.  Instead, the user must explicitly make a call
to `\Instagram\Api::getMoreMedias` in order to fetch medias or to
`getMoreIgtvs` to fetch IGTVs

1 of 2 new or added lines in 1 file covered. (50.0%)

3 existing lines in 2 files now uncovered.

2124 of 2300 relevant lines covered (92.35%)

15.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.84
/src/Instagram/Model/Media.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Instagram\Model;
6

7
use Instagram\Utils\InstagramHelper;
8

9
class Media
10
{
11
    const TYPE_IMAGE = 'image';
12
    const TYPE_VIDEO = 'video';
13
    const TYPE_CAROUSEL = 'carousel';
14

15
    const MEDIA_TYPE_IMAGE = 1;
16
    const MEDIA_TYPE_VIDEO = 2;
17
    const MEDIA_TYPE_CAROUSEL = 8;
18

19
    /**
20
     * @var int
21
     */
22
    private $id;
23

24
    /**
25
     * @var string
26
     */
27
    private $shortCode;
28

29
    /**
30
     * @var string
31
     */
32
    private $typeName = '';
33

34
    /**
35
     * @var int
36
     */
37
    private $height;
38

39
    /**
40
     * @var int
41
     */
42
    private $width;
43

44
    /**
45
     * @var string
46
     */
47
    private $thumbnailSrc;
48

49
    /**
50
     * @var string
51
     */
52
    private $link;
53

54
    /**
55
     * @var \DateTime
56
     */
57
    private $date;
58

59
    /**
60
     * @var string
61
     */
62
    private $displaySrc;
63

64
    /**
65
     * @var string
66
     */
67
    private $caption;
68

69
    /**
70
     * @var int
71
     */
72
    private $comments;
73

74
    /**
75
     * @var int
76
     */
77
    private $likes;
78

79
    /**
80
     * @var array
81
     */
82
    private $thumbnails = [];
83

84
    /**
85
     * @var mixed
86
     */
87
    private $location;
88

89
    /**
90
     * @var bool
91
     */
92
    private $video = false;
93

94
    /**
95
     * @var string
96
     */
97
    private $videoUrl = '';
98

99
    /**
100
     * @var int
101
     */
102
    private $videoViewCount = 0;
103

104
    /**
105
     * @var string
106
     */
107
    private $accessibilityCaption;
108

109
    /**
110
     * @var bool
111
     */
112
    private $igtv = false;
113

114
    /**
115
     * @var array
116
     */
117
    private $hashtags = [];
118

119
    /**
120
     * @var int
121
     */
122
    private $ownerId;
123

124
    /**
125
     * @return int
126
     */
127
    public function getId(): int
128
    {
129
        return $this->id;
10✔
130
    }
131

132
    /**
133
     * @param int $id
134
     */
135
    public function setId(int $id): void
136
    {
137
        $this->id = $id;
50✔
138
    }
10✔
139

140
    /**
141
     * @return string
142
     */
143
    public function getShortCode(): string
144
    {
145
        return $this->shortCode;
10✔
146
    }
147

148
    /**
149
     * @param string $shortCode
150
     */
151
    public function setShortCode(string $shortCode): void
152
    {
153
        $this->shortCode = $shortCode;
50✔
154
    }
10✔
155

156
    /**
157
     * @return string
158
     */
159
    public function getTypeName(): string
160
    {
161
        return $this->typeName;
5✔
162
    }
163

164
    /**
165
     * @param string $typeName
166
     */
167
    public function setTypeName(string $typeName): void
168
    {
169
        $this->typeName = $typeName;
45✔
170
    }
9✔
171

172
    /**
173
     * @return int
174
     */
175
    public function getHeight(): int
176
    {
177
        return $this->height;
5✔
178
    }
179

180
    /**
181
     * @param int $height
182
     */
183
    public function setHeight(int $height): void
184
    {
185
        $this->height = $height;
50✔
186
    }
10✔
187

188
    /**
189
     * @return int
190
     */
191
    public function getWidth(): int
192
    {
193
        return $this->width;
5✔
194
    }
195

196
    /**
197
     * @param int $width
198
     */
199
    public function setWidth(int $width): void
200
    {
201
        $this->width = $width;
50✔
202
    }
10✔
203

204
    /**
205
     * @return string
206
     */
207
    public function getThumbnailSrc(): string
208
    {
209
        return $this->thumbnailSrc;
5✔
210
    }
211

212
    /**
213
     * @param string $thumbnailSrc
214
     */
215
    public function setThumbnailSrc(string $thumbnailSrc): void
216
    {
217
        $this->thumbnailSrc = $thumbnailSrc;
50✔
218
    }
10✔
219

220
    /**
221
     * @return \DateTime
222
     */
223
    public function getDate(): \DateTime
224
    {
225
        return $this->date;
5✔
226
    }
227

228
    /**
229
     * @param \DateTime $date
230
     */
231
    public function setDate(\DateTime $date): void
232
    {
233
        $this->date = $date;
50✔
234
    }
10✔
235

236
    /**
237
     * @return ?string
238
     */
239
    public function getDisplaySrc(): ?string
240
    {
241
        return $this->displaySrc;
5✔
242
    }
243

244
    /**
245
     * @param string $displaySrc
246
     */
247
    public function setDisplaySrc(string $displaySrc): void
248
    {
249
        $this->displaySrc = $displaySrc;
50✔
250
    }
10✔
251

252
    /**
253
     * @return string
254
     */
255
    public function getCaption(): ?string
256
    {
257
        return $this->caption;
5✔
258
    }
259

260
    /**
261
     * @param string $caption
262
     */
263
    public function setCaption(?string $caption): void
264
    {
265
        $this->caption = $caption;
50✔
266
    }
10✔
267

268
    /**
269
     * @return int
270
     */
271
    public function getComments(): int
272
    {
273
        return $this->comments;
5✔
274
    }
275

276
    /**
277
     * @param int $comments
278
     */
279
    public function setComments(int $comments): void
280
    {
281
        $this->comments = $comments;
50✔
282
    }
10✔
283

284
    /**
285
     * @return int
286
     */
287
    public function getLikes(): int
288
    {
289
        return $this->likes;
5✔
290
    }
291

292
    /**
293
     * @param int $likes
294
     */
295
    public function setLikes(int $likes): void
296
    {
297
        $this->likes = $likes;
50✔
298
    }
10✔
299

300
    /**
301
     * @return string
302
     */
303
    public function getLink(): string
304
    {
305
        return $this->link;
10✔
306
    }
307

308
    /**
309
     * @param string $link
310
     */
311
    public function setLink(string $link): void
312
    {
313
        $this->link = $link;
50✔
314
    }
10✔
315

316
    /**
317
     * @return array
318
     */
319
    public function getThumbnails(): array
320
    {
321
        return $this->thumbnails;
5✔
322
    }
323

324
    /**
325
     * @param array $thumbnails
326
     */
327
    public function setThumbnails(array $thumbnails): void
328
    {
329
        $this->thumbnails = $thumbnails;
40✔
330
    }
8✔
331

332
    /**
333
     * @return mixed
334
     */
335
    public function getLocation()
336
    {
337
        return $this->location;
5✔
338
    }
339

340
    /**
341
     * @param \StdClass $location
342
     */
343
    public function setLocation(\StdClass $location): void
344
    {
345
        $this->location = $location;
15✔
346
    }
3✔
347

348
    /**
349
     * @return bool
350
     */
351
    public function isVideo(): bool
352
    {
353
        return $this->video;
5✔
354
    }
355

356
    /**
357
     * @param bool $video
358
     */
359
    public function setVideo(bool $video): void
360
    {
361
        $this->video = $video;
50✔
362
    }
10✔
363

364
    /**
365
     * @return ?string
366
     */
367
    public function getVideoUrl(): ?string
368
    {
369
        return $this->videoUrl;
5✔
370
    }
371

372
    /**
373
     * @param ?string $videoUrl
374
     */
375
    public function setVideoUrl(?string $videoUrl): void
376
    {
377
        $this->videoUrl = $videoUrl;
15✔
378
    }
3✔
379

380
    /**
381
     * @return int
382
     */
383
    public function getVideoViewCount(): int
384
    {
385
        return $this->videoViewCount;
5✔
386
    }
387

388
    /**
389
     * @param int $videoViewCount
390
     */
391
    public function setVideoViewCount(int $videoViewCount): void
392
    {
393
        $this->videoViewCount = $videoViewCount;
45✔
394
    }
9✔
395

396
    /**
397
     * @return array
398
     */
399
    public function toArray(): array
400
    {
401
        return [
8✔
402
            'id'                   => $this->id,
10✔
403
            'shortcode'            => $this->shortCode,
10✔
404
            'typeName'             => $this->typeName,
10✔
405
            'height'               => $this->height,
10✔
406
            'width'                => $this->width,
10✔
407
            'thumbnailSrc'         => $this->thumbnailSrc,
10✔
408
            'link'                 => $this->link,
10✔
409
            'date'                 => $this->date,
10✔
410
            'displaySrc'           => $this->displaySrc,
10✔
411
            'caption'              => $this->caption,
10✔
412
            'comments'             => $this->comments,
10✔
413
            'likes'                => $this->likes,
10✔
414
            'thumbnails'           => $this->thumbnails,
10✔
415
            'location'             => $this->location,
10✔
416
            'video'                => $this->video,
10✔
417
            'videoUrl'             => $this->videoUrl,
10✔
418
            'igtv'                 => $this->igtv,
10✔
419
            'videoViewCount'       => $this->videoViewCount,
10✔
420
            'accessibilityCaption' => $this->accessibilityCaption,
10✔
421
            'hashtags'             => $this->hashtags
10✔
422
        ];
8✔
423
    }
424

425
    /**
426
     * @return array
427
     */
428
    public function __serialize(): array
429
    {
430
        return $this->toArray();
5✔
431
    }
432

433

434
    /**
435
     * @return string|null
436
     */
437
    public function getAccessibilityCaption(): ?string
438
    {
UNCOV
439
        return $this->accessibilityCaption;
×
440
    }
441

442
    /**
443
     * @param string|null $accessibilityCaption
444
     */
445
    public function setAccessibilityCaption(?string $accessibilityCaption): void
446
    {
447
        $this->accessibilityCaption = $accessibilityCaption;
35✔
448
    }
7✔
449

450
    /**
451
     * @return bool
452
     */
453
    public function isIgtv(): bool
454
    {
455
        return $this->igtv;
5✔
456
    }
457

458
    /**
459
     * @param bool $igtv
460
     */
461
    public function setIgtv(bool $igtv): void
462
    {
463
        $this->igtv = $igtv;
25✔
464
    }
5✔
465

466
    /**
467
     * @return array
468
     */
469
    public function getHashtags(): array
470
    {
471
        return InstagramHelper::buildHashtags($this->caption);
5✔
472
    }
473

474
    /**
475
     * @param array $hashtags
476
     */
477
    public function setHashtags(array $hashtags): void
478
    {
479
        $this->hashtags = $hashtags;
50✔
480
    }
10✔
481

482
    /**
483
     * @return int
484
     */
485
    public function getOwnerId(): ?int
486
    {
487
        return $this->ownerId;
5✔
488
    }
489

490
    /**
491
     * @param int $ownerId
492
     */
493
    public function setOwnerId(int $ownerId): void
494
    {
495
        $this->ownerId = $ownerId;
50✔
496
    }
10✔
497
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc