Factory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A make() 0 3 1
A __construct() 0 4 2
1
<?php
2
namespace Cohensive\OEmbed;
3
4
class Factory
5
{
6
    /**
7
     * Configs.
8
     */
9
    protected array $config;
10
11
    /**
12
     * Create Embed factory and set providers from config.
13
     */
14
    public function __construct(?array $config = null)
15
    {
16
        if (is_null($config)) {
17
            $this->config = require('./resources/config.php');
18
        }
19
    }
20
21
    /**
22
     * Create a new OEmbed instance.
23
     */
24
    public function make(): OEmbed
25
    {
26
        return new OEmbed($this->config);
27
    }
28
29
    /**
30
     * Helper method to quickly get embed data from OEmbed instance.
31
     */
32
    public function get(string $url, array $options = []): ?Embed
33
    {
34
        return $this->make()->withOptions($options)->get($url);
35
    }
36
}
37