Issues (5)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Factory.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Irazasyed\VideoDownloader;
4
5
use Irazasyed\VideoDownloader\Exceptions\VideoDownloaderException;
6
use Irazasyed\VideoDownloader\Providers\Facebook;
7
use Irazasyed\VideoDownloader\Providers\ProviderInterface;
8
9
class Factory
10
{
11
    /**
12
     * @var ProviderInterface
13
     */
14
    protected $provider;
15
16
    /**
17
     * @var array Get Default Available Providers.
18
     */
19
    protected $providers = [
20
        'facebook' => Facebook::class,
21
    ];
22
23
    /**
24
     * Factory constructor.
25
     *
26
     * @param null $provider
27
     */
28
    public function __construct($provider = null)
29
    {
30
        if (isset($provider)) {
31
            return $this->make($provider);
0 ignored issues
show
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
32
        }
33
    }
34
35
    /**
36
     * @param $provider
37
     *
38
     * @throws VideoDownloaderException
39
     *
40
     * @return $this
41
     */
42
    public function make($provider)
43
    {
44
        if (!is_object($provider)) {
45
            if (array_key_exists($provider, $this->providers)) {
46
                $provider = $this->providers[$provider];
47
            } elseif (!class_exists($provider)) {
48
                throw new VideoDownloaderException(
49
                    sprintf(
50
                        'Provider class "%s" not found! Please make sure the class exists.',
51
                        $provider
52
                    )
53
                );
54
            }
55
56
            $provider = new $provider();
57
        }
58
59
        if ($provider instanceof ProviderInterface) {
60
            /*
61
             * At this stage we definitely have a proper provider to use.
62
             *
63
             * @var Provider $provider
64
             */
65
            return $this->provider = $provider;
0 ignored issues
show
Documentation Bug introduced by
It seems like $provider of type object<Irazasyed\VideoDownloader\Provider> is incompatible with the declared type object<Irazasyed\VideoDo...ders\ProviderInterface> of property $provider.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
66
        }
67
68
        throw new VideoDownloaderException(
69
            sprintf(
70
                'Provider class "%s" should be an instance of "Irazasyed\VideoDownloader\Providers\ProviderInterface"',
71
                get_class($provider)
72
            )
73
        );
74
    }
75
76
    /**
77
     * Gets Video Download Links with Meta Data from the Provider.
78
     * Returns HD & SD Quality Links.
79
     *
80
     * @param $url
81
     *
82
     * @return array
83
     */
84
    public function getVideoInfo($url)
85
    {
86
        return $this->provider->getVideoInfo($url);
87
    }
88
89
    /**
90
     * Download remote file from server
91
     * and save it locally using HTTP Client.
92
     *
93
     * @param string $url            The URL to Remote File to Download.
94
     * @param string $dstFilename    Destination Filename (Accepts File Path too).
95
     * @param bool   $isAsyncRequest
96
     *
97
     * @return string
98
     */
99
    public function download($url, $dstFilename, $isAsyncRequest = false)
0 ignored issues
show
The parameter $dstFilename is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $isAsyncRequest is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
100
    {
101
        return $this->provider->download($url);
102
    }
103
104
    /**
105
     * @param null $provider
106
     *
107
     * @return ProviderInterface
108
     */
109
    public function getInstance($provider = null)
110
    {
111
        if (isset($this->provider)) {
112
            return $this->provider;
113
        }
114
115
        return $this->providers[$provider];
116
    }
117
118
    /**
119
     * Add Provider to List.
120
     *
121
     * @param ProviderInterface $provider
122
     *
123
     * @return $this
124
     */
125
    public function setProvider(ProviderInterface $provider)
126
    {
127
        $class = get_class($provider);
128
        if (!array_key_exists($class, $this->providers)) {
129
            $this->providers[$class] = $provider;
130
        }
131
132
        return $this;
133
    }
134
135
    /**
136
     * Returns Current Provider Instance.
137
     */
138
    public function getProvider()
139
    {
140
        return $this->provider;
141
    }
142
}
143