Issues (1)

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.

Model/Entity/Coordinates/Coordinates.php (1 issue)

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 Wolnosciowiec\CoordinatesBundle\Model\Entity\Coordinates;
4
5
/**
6
 * Coordinates
7
 * ===========
8
 *
9
 * @package Wolnosciowiec\CoordinatesBundle\Model\Entity\Coordinates
10
 */
11
class Coordinates
12
{
13
    /** @var float $lat */
14
    protected $lat;
15
16
    /** @var float $lon */
17
    protected $lon;
18
19
    /** @var float $distance */
20
    protected $distance = 0.0;
21
22
    /**
23
     * @param float $lat Latitude
24
     * @param float $lon Longitude
25
     * @param int $distance Defaults to 20 km
26
     */
27
    public function __construct($lat, $lon, $distance = 20)
28
    {
29
        if (!is_float($lat) || !is_float($lon) || $lat <= -90.0 || $lon <= -90.0) {
30
            throw new \InvalidArgumentException('$lat and $lon should be float, and in acceptable range, got $lat = ' . $lat . ', $lon = ' . $lon);
31
        }
32
33
        $this->lat = $lat;
34
        $this->lon = $lon;
35
        $this->distance = $distance;
0 ignored issues
show
Documentation Bug introduced by
The property $distance was declared of type double, but $distance is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
36
    }
37
38
    /**
39
     * @return float
40
     */
41
    public function getLatitude()
42
    {
43
        return $this->lat;
44
    }
45
46
    /**
47
     * @return float
48
     */
49
    public function getLongitude()
50
    {
51
        return $this->lon;
52
    }
53
54
    /**
55
     * @param Coordinates $coordinates
56
     * @return Distance
57
     */
58
    public function compareWith(Coordinates $coordinates)
59
    {
60
        return new Distance(
61
            $this->getLatitude(),
62
            $this->getLongitude(),
63
64
            $coordinates->getLatitude(),
65
            $coordinates->getLongitude()
66
        );
67
    }
68
69
    /**
70
     * @return BoundingBox
71
     */
72
    public function getBoundingSquare()
73
    {
74
        return new BoundingBox(
75
            $this->getLatitude(),
76
            $this->getLongitude(),
77
            $this->getMaxAcceptedDistance()
78
        );
79
    }
80
81
    /**
82
     * @return float|int
83
     */
84
    public function getMaxAcceptedDistance()
85
    {
86
        return $this->distance;
87
    }
88
89
    /**
90
     * @return float|int
91
     */
92
    public function getDistanceInMeters()
93
    {
94
        return $this->getMaxAcceptedDistance() * 1000;
95
    }
96
97
    /**
98
     * @return float|int
99
     */
100
    public function getLongtitudeUnit()
101
    {
102
        return 2 * M_PI * 6371000 / 360;
103
    }
104
105
    /**
106
     * @return float|int
107
     */
108
    public function getLatitudeInMeters()
109
    {
110
        return (1 - $this->getLatitude() / 90) * 2 *M_PI * 6371000 / 360;
111
    }
112
113
    /**
114
     * @param float $distance
115
     */
116
    public function setMaxAcceptedDistance(float $distance)
117
    {
118
        $this->distance = $distance;
119
    }
120
}
121