This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | |||
3 | namespace Vanbrabantf\NpmStatFetcher; |
||
4 | |||
5 | use Cake\Chronos\Chronos; |
||
6 | use DateTimeInterface; |
||
7 | use Vanbrabantf\NpmStatFetcher\Dates\DateChecker; |
||
0 ignored issues
–
show
|
|||
8 | use Vanbrabantf\NpmStatFetcher\Dates\DateRange; |
||
9 | use Vanbrabantf\NpmStatFetcher\Package\Package; |
||
10 | use Vanbrabantf\NpmStatFetcher\Statistics\DownloadStatistics; |
||
11 | |||
12 | class StatFetcher |
||
13 | { |
||
14 | /** |
||
15 | * @var NpmRegistryRepository |
||
16 | */ |
||
17 | private $repository; |
||
18 | |||
19 | /** |
||
20 | * @param NpmRegistryRepository $repository |
||
21 | */ |
||
22 | public function __construct(NpmRegistryRepository $repository = null) |
||
23 | { |
||
24 | $this->repository = $repository ?: new NpmRegistryRepository(ClientFactory::Build()); |
||
25 | } |
||
26 | |||
27 | |||
28 | /** |
||
29 | * @param string $packageName |
||
30 | * |
||
31 | * @return DownloadStatistics |
||
32 | */ |
||
33 | public function getDownloadsLastDay(string $packageName): DownloadStatistics |
||
34 | { |
||
35 | $package = new Package($packageName); |
||
36 | |||
37 | $resource = $this->repository->getResourceByPath( |
||
38 | '/downloads/point/last-day/' . $package |
||
39 | ); |
||
40 | |||
41 | return DownloadStatistics::fromJson($package, $resource); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param string $packageName |
||
46 | * |
||
47 | * @return DownloadStatistics |
||
48 | */ |
||
49 | View Code Duplication | public function getDownloadsLastWeek(string $packageName): DownloadStatistics |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
50 | { |
||
51 | $package = new Package($packageName); |
||
52 | |||
53 | $resource = $this->repository->getResourceByPath( |
||
54 | '/downloads/point/last-week/' . $package |
||
55 | ); |
||
56 | |||
57 | return DownloadStatistics::fromJson($package, $resource); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param string $packageName |
||
62 | * |
||
63 | * @return DownloadStatistics |
||
64 | */ |
||
65 | View Code Duplication | public function getDownloadsLastMonth(string $packageName): DownloadStatistics |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
66 | { |
||
67 | $package = new Package($packageName); |
||
68 | |||
69 | $resource = $this->repository->getResourceByPath( |
||
70 | '/downloads/point/last-month/' . $package |
||
71 | ); |
||
72 | |||
73 | return DownloadStatistics::fromJson($package, $resource); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param string $packageName |
||
78 | * |
||
79 | * @return DownloadStatistics |
||
80 | */ |
||
81 | View Code Duplication | public function getDownloadsLastYear(string $packageName): DownloadStatistics |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
82 | { |
||
83 | $package = new Package($packageName); |
||
84 | |||
85 | $resource = $this->repository->getResourceByPath( |
||
86 | '/downloads/point/last-year/' . $package |
||
87 | ); |
||
88 | |||
89 | return DownloadStatistics::fromJson($package, $resource); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @param string $packageName |
||
94 | * |
||
95 | * @return DownloadStatistics |
||
96 | */ |
||
97 | public function getDownloads(string $packageName): DownloadStatistics |
||
98 | { |
||
99 | $package = new Package($packageName); |
||
100 | $dateRange = new DateRange(new Chronos('1999-01-01'), new Chronos()); |
||
101 | |||
102 | $resource = $this->repository->getResourceByPath( |
||
103 | '/downloads/point/' . $dateRange->getStartDate()->format('Y-m-d') . |
||
104 | ':' . $dateRange->getEndDate()->format('Y-m-d') . '/' . $package |
||
105 | ); |
||
106 | |||
107 | return DownloadStatistics::fromJson($package, $resource); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param string $packageName |
||
112 | * @param DateTimeInterface $start |
||
113 | * @param DateTimeInterface $end |
||
114 | * |
||
115 | * @return DownloadStatistics |
||
116 | */ |
||
117 | public function getDownloadsBetweenDates( |
||
118 | string $packageName, |
||
119 | DateTimeInterface $start, |
||
120 | DateTimeInterface $end |
||
121 | ): DownloadStatistics { |
||
122 | return $this->getDownloadsInDateRange( |
||
123 | $packageName, |
||
124 | new DateRange($start, $end) |
||
125 | ); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * @param string $packageName |
||
130 | * @param DateRange $dateRange |
||
131 | * |
||
132 | * @return DownloadStatistics |
||
133 | */ |
||
134 | public function getDownloadsInDateRange( |
||
135 | string $packageName, |
||
136 | DateRange $dateRange |
||
137 | ): DownloadStatistics { |
||
138 | $package = new Package($packageName); |
||
139 | |||
140 | $resource = $this->repository->getResourceByPath( |
||
141 | '/downloads/point/' . $dateRange->getStartDate()->format('Y-m-d') . |
||
142 | ':' . $dateRange->getEndDate()->format('Y-m-d') . '/' . $package |
||
143 | ); |
||
144 | |||
145 | return DownloadStatistics::fromJson($package, $resource); |
||
146 | } |
||
147 | } |
||
148 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths