Issues (88)

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.

code/model/VimeoDataObject.php (73 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
/**
4
 *@author nicolaas[at]sunnysideup.co.nz
5
 *
6
 *
7
 **/
8
9
class VimeoDataObject extends DataObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    private static $db = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
        "Title" => "Varchar(100)",
13
        "VimeoCode" => "Int",
14
        "HTMLSnippet" => "HTMLText",
15
        "Data" => "Text"
16
    );
17
18
    private static $casting = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $casting is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
        "FullName" => "Text",
20
        "Icon" => "HTMLText",
21
        "IconLink" => "Varchar",
22
        "FullImage" => "HTMLText",
23
        "FullImageLink" => "Varchar"
24
    );
25
26
    private static $searchable_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $searchable_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
27
        "Title" => "PartialMatchFilter",
28
        "VimeoCode"
29
    );
30
31
    private static $summary_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
32
        "Icon" => "Icon",
33
        "Title" => "Title",
34
    );
35
36
    private static $singular_name = "Vimeo Video";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $singular_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
37
38
    private static $plural_name = "Vimeo Videos";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $plural_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
39
40
    private static $default_sort = "Title ASC";
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $default_sort is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
41
42
    private static $vimeo_base_url = "http://vimeo.com/api/oembed.xml?url=http%3A//vimeo.com/";//The exact width of the video. Defaults to original size.
0 ignored issues
show
The property $vimeo_base_url is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
43
44
    private static $width = null;//The exact width of the video. Defaults to original size.
0 ignored issues
show
The property $width is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
45
46
    private static $maxwidth = null;////Same as width, but video will not exceed original size.
0 ignored issues
show
The property $maxwidth is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
47
48
    private static $height = null;//The exact height of the video. Defaults to original size.
0 ignored issues
show
The property $height is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
49
50
    private static $maxheight = null;//Same as height, but video will not exceed original size.
0 ignored issues
show
The property $maxheight is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
51
52
    private static $byline = null;//Show the byline on the video. Defaults to true.
0 ignored issues
show
The property $byline is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
53
54
    private static $title = null;//Show the title on the video. Defaults to true.
0 ignored issues
show
The property $title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
55
56
    private static $portrait = null;//// Show the user's portrait on the video. Defaults to true.
0 ignored issues
show
The property $portrait is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
57
58
    private static $color = null;// Specify the color of the video controls.
0 ignored issues
show
The property $color is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
59
60
    private static $callback = null;//When returning JSON, wrap in this function.
0 ignored issues
show
The property $callback is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
61
62
    private static $autoplay = null;//Automatically start playback of the video. Defaults to false.
0 ignored issues
show
The property $autoplay is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
63
64
    private static $xhtml = null;// Make the embed code XHTML compliant. Defaults to true.
0 ignored issues
show
The property $xhtml is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
65
66
    private static $api = null;// Enable the Javascript API for Moogaloop. Defaults to false.
0 ignored issues
show
The property $api is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
67
68
    private static $wmode = null;//add the "wmode" parameter. Can be either transparent or opaque.
0 ignored issues
show
The property $wmode is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
69
70
    private static $iframe;// Use our new embed code. Defaults to true. NEW!
0 ignored issues
show
The property $iframe is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
71
72
    protected $dataAsArray = array();
73
74
    protected $variables = array(
75
        "type",
76
        "version",
77
        "provider_name",
78
        "provider_url",
79
        "title",
80
        "author_name",
81
        "author_url",
82
        "is_plus",
83
        "html",
84
        "width",
85
        "height",
86
        "duration",
87
        "description",
88
        "thumbnail_url",
89
        "thumbnail_width",
90
        "thumbnail_height",
91
        "video_id"
92
    );
93
94
    /**
95
     * do not retrieve data from vimeo server ...
96
     * for internal use only
97
     * @var Boolean
98
     */
99
    private $doNotRetrieveData = false;
100
101
    public function getCMSFields()
102
    {
103
        $fields = parent::getCMSFields();
104
        $fields->removeByName("HTMLSnippet");
105
        $fields->removeByName("Data");
106
        $fields->addFieldToTab("Root.Main", new LiteralField("HTMLSnippet", $this->HTML($noCaching = false)));
107
        $this->getDataAsArray();
108
        if (is_array($this->dataAsArray) && count($this->dataAsArray)) {
109
            foreach ($this->dataAsArray as $name => $value) {
110
                $fields->addFieldToTab("Root.Details", new ReadOnlyField($name, $name, $value));
111
            }
112
        }
113
        return $fields;
114
    }
115
116
    /**
117
     * casted variable
118
     * @return string
119
     */
120
    public function getFullName()
121
    {
122
        return $this->Title." (".$this->VimeoCode.")";
0 ignored issues
show
The property Title does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property VimeoCode does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
123
    }
124
125
    /**
126
     * alias for getVariable
127
     * @param String $name
128
     * @return Varchar
0 ignored issues
show
Should the return type not be Varchar|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
129
     */
130
    public function MetaDataVariable($name)
131
    {
132
        return $this->getMetaDataVariable($name);
133
    }
134
135
    /**
136
     *
137
     * @param String - name of variable
138
     *
139
     * @return Varchar Object
0 ignored issues
show
Should the return type not be Varchar|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
140
     */
141 View Code Duplication
    public function getMetaDataVariable($name)
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.

Loading history...
142
    {
143
        $this->getDataAsArray();
144
        if (!empty($this->dataAsArray[$name])) {
145
            return DBField::create_field("Varchar", $this->dataAsArray[$name]);
146
        }
147
        return null;
148
    }
149
150
    /**
151
     * return icon as <img tag>
152
     * @return String
0 ignored issues
show
Should the return type not be DBField?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
153
     */
154
    public function getIcon()
155
    {
156 View Code Duplication
        if (!count($this->dataAsArray)) {
0 ignored issues
show
This code seems to be duplicated across 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.

Loading history...
157
            //remove non-ascii characters as they were causing havoc...
158
            $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
159
            $this->dataAsArray = $this->safelyUnserialize($this->Data);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
160
        }
161
        if (!empty($this->dataAsArray["thumbnail_url"])) {
162
            $v = "<img src=\"".$this->dataAsArray["thumbnail_url"]."\" width=\"".$this->dataAsArray["thumbnail_width"]."\" height=\"".$this->dataAsArray["thumbnail_height"]."\" alt=\"".Convert::raw2att($this->Title)."\"/>";
0 ignored issues
show
The property Title does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
163
        } else {
164
            $v = "[".$this->Title."]";
0 ignored issues
show
The property Title does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
165
        }
166
        return DBField::create_field("HTMLText", $v);
167
    }
168
169
    /**
170
     * returns icon as myimage.png
171
     * @return String
0 ignored issues
show
Should the return type not be DBField|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
172
     */
173 View Code Duplication
    public function getIconLink()
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.

Loading history...
174
    {
175
        $this->getDataAsArray();
176
        if (!empty($this->dataAsArray["thumbnail_url"])) {
177
            return DBField::create_field("Varchar", $this->dataAsArray["thumbnail_url"]);
178
        }
179
        return null;
180
    }
181
182
    /**
183
     * return icon as <img tag>
184
     * @return String
0 ignored issues
show
Should the return type not be DBField?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
185
     */
186
    public function getFullImage()
187
    {
188 View Code Duplication
        if (!count($this->dataAsArray)) {
0 ignored issues
show
This code seems to be duplicated across 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.

Loading history...
189
            //remove non-ascii characters as they were causing havoc...
190
            $this->Data = preg_replace('/[^(\x20-\x7F)]*/', '', $this->Data);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
191
            $this->dataAsArray = $this->safelyUnserialize($this->Data);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
192
        }
193
        if (!empty($this->dataAsArray["thumbnail_url"])) {
194
            $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]);
195
            $v = "<img src=\"".$imageLink."\" alt=\"".Convert::raw2att($this->Title)."\"/>";
0 ignored issues
show
The property Title does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
196
        } else {
197
            $v = "[".$this->Title."]";
0 ignored issues
show
The property Title does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
198
        }
199
        return DBField::create_field("HTMLText", $v);
200
    }
201
202
    /**
203
     * returns icon as myimage.png
204
     * @return String
0 ignored issues
show
Should the return type not be DBField|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
205
     */
206
    public function getFullImageLink()
207
    {
208
        $this->getDataAsArray();
209
        if (!empty($this->dataAsArray["thumbnail_url"])) {
210
            $imageLink = str_replace("_295x166", "", $this->dataAsArray["thumbnail_url"]);
211
            return DBField::create_field("Varchar", $imageLink);
212
        }
213
        return null;
214
    }
215
216
    /**
217
     * returns the HTML Embed code
218
     * @return String
219
     */
220
    public function HTML($noCaching = false)
0 ignored issues
show
HTML uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
221
    {
222
        if ($noCaching || strlen($this->HTMLSnippet) < 17 || !$this->Data || isset($_GET["flush"])) {
0 ignored issues
show
The property HTMLSnippet does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
223
            //
224
            $this->updateData();
225
        }
226
        return $this->HTMLSnippet;
0 ignored issues
show
The property HTMLSnippet does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
227
    }
228
229
    /**
230
     * turns the saved serialized data into an array to return
231
     * if there is no data then it will try to retrieve and save it
232
     * then return it.
233
     * @return Array
234
     */
235
    protected function getDataAsArray()
236
    {
237
        if ($this->dataAsArray) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->dataAsArray of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
238
            return $this->dataAsArray;
239
        }
240
        if (!$this->Data) {
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
241
            $this->updateData();
242
        }
243
        $this->dataAsArray = $this->safelyUnserialize($this->Data);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
244
        return $this->dataAsArray;
245
    }
246
247
    /**
248
     * retrieves data from Vimeo Site
249
     *
250
     * @return Array
251
     */
252
    protected function updateData($writeToDatabase = true)
253
    {
254
        if ($this->doNotRetrieveData) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
255
            //do nothing
256
        } elseif ($this->VimeoCode) {
0 ignored issues
show
The property VimeoCode does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
257
            $get = array();
258
            if ($width = $this->Config()->get("width")) {
259
                $get["width"] = $width;
260
            }
261
            if ($max_width = $this->Config()->get("maxwidth")) {
262
                $get["maxwidth"] = $max_width;
263
            }
264
            if ($height = $this->Config()->get("height")) {
265
                $get["height"] = $height;
266
            }
267
            if ($maxheight = $this->Config()->get("maxheight")) {
268
                $get["maxheight"] = $maxheight;
269
            }
270
            if ($byline = $this->Config()->get("byline")) {
271
                $get["byline"] = $byline;
272
            }
273
            if ($title = $this->Config()->get("title")) {
274
                $get["title"] = $title;
275
            }
276
            if ($portrait = $this->Config()->get("portrait")) {
277
                $get["portrait"] = $portrait;
278
            }
279
            if ($color = $this->Config()->get("color")) {
280
                $get["color"] = $color;
281
            }
282
            if ($callback = $this->Config()->get("callback")) {
283
                $get["callback"] = $callback;
284
            }
285
            if ($autoplay = $this->Config()->get("autoplay ")) {
286
                $get["autoplay"] = $autoplay;
287
            }
288
            if ($xhtml = $this->Config()->get("xhtml")) {
289
                $get["xhtml"] = $xhtml;
290
            }
291
            if ($api = $this->Config()->get("api")) {
292
                $get["api"] = $api;
293
            }
294
            if ($wmode = $this->Config()->get("wmode")) {
295
                $get["wmode"] = $wmode;
296
            }
297
            if ($iframe = $this->Config()->get("iframe")) {
298
                $get["iframe"] = $iframe;
299
            }
300
            $url = '';
301
            $url .= $this->Config()->get("vimeo_base_url").$this->VimeoCode;
0 ignored issues
show
The property VimeoCode does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
302
            if (is_array($get) && count($get)) {
303
                foreach ($get as $key => $value) {
304
                    $get[$key] = $key."=".urlencode($value);
305
                }
306
                $url .= "?".implode("&", $get);
307
            }
308
            $ch = curl_init();
309
            curl_setopt($ch, CURLOPT_URL, $url);
310
            curl_setopt($ch, CURLOPT_HEADER, 0);
311
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
312
            $data = curl_exec($ch);
313
            $array = $this->my_xml2array($data);
314
            foreach ($this->variables as $variable) {
315
                $data_array = $this->get_value_by_path($array, 'oembed/'.$variable);
316
                if (isset($data_array["name"]) && isset($data_array["value"])) {
317
                    $this->dataAsArray[$data_array["name"]] = $data_array["value"];
318
                } else {
319
                    $this->dataAsArray[$variable] = null;
320
                }
321
            }
322
            $this->Data = $this->safelySerialize($this->dataAsArray);
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
323
            $this->HTMLSnippet = $this->dataAsArray["html"];
0 ignored issues
show
The property HTMLSnippet does not exist on object<VimeoDataObject>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
324
            if ($writeToDatabase) {
325
                $this->write();
326
            }
327
        }
328
        return $this->Data;
0 ignored issues
show
The property Data does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
329
    }
330
331
332
    public function onBeforeWrite()
333
    {
334
        parent::onBeforeWrite();
335
        $this->VimeoCode = intval($this->VimeoCode);
0 ignored issues
show
The property VimeoCode does not exist on object<VimeoDataObject>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
The property VimeoCode does not exist on object<VimeoDataObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
336
        $this->updateData(false);
337
    }
338
339
340
    //SOURCE: http://php.net/manual/en/function.xml-parse.php
341
    private function my_xml2array($contents)
342
    {
343
        $parser = xml_parser_create('');
344
        if (!$parser) {
345
            return false;
346
        }
347
        xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
348
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
349
        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
350
        xml_parse_into_struct($parser, trim($contents), $xml_values);
351
        xml_parser_free($parser);
352
        if (!$xml_values) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $xml_values of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
353
            return array();
354
        }
355
        $xml_array = array();
356
        $last_tag_ar =& $xml_array;
357
        $parents = array();
358
        $last_counter_in_tag = array(1=>0);
359
        foreach ($xml_values as $data) {
360
            switch ($data['type']) {
361
                case 'open':
362
                    $last_counter_in_tag[$data['level']+1] = 0;
363
                    $new_tag = array('name' => $data['tag']);
364
                    if (isset($data['attributes'])) {
365
                        $new_tag['attributes'] = $data['attributes'];
366
                    }
367 View Code Duplication
                    if (isset($data['value']) && trim($data['value'])) {
0 ignored issues
show
This code seems to be duplicated across 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.

Loading history...
368
                        $new_tag['value'] = trim($data['value']);
369
                    }
370
                    $last_tag_ar[$last_counter_in_tag[$data['level']]] = $new_tag;
371
                    $parents[$data['level']] =& $last_tag_ar;
372
                    $last_tag_ar =& $last_tag_ar[$last_counter_in_tag[$data['level']]++];
373
                    break;
374
                case 'complete':
375
                    $new_tag = array('name' => $data['tag']);
376
                    if (isset($data['attributes'])) {
377
                        $new_tag['attributes'] = $data['attributes'];
378
                    }
379 View Code Duplication
                    if (isset($data['value']) && trim($data['value'])) {
0 ignored issues
show
This code seems to be duplicated across 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.

Loading history...
380
                        $new_tag['value'] = trim($data['value']);
381
                    }
382
                    $last_count = count($last_tag_ar)-1;
0 ignored issues
show
$last_count is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
383
                    $last_tag_ar[$last_counter_in_tag[$data['level']]++] = $new_tag;
384
                    break;
385
                case 'close':
386
                    $last_tag_ar =& $parents[$data['level']];
387
                    break;
388
                default:
389
                    break;
390
            };
391
        }
392
        return $xml_array;
393
    }
394
395
    //
396
    // use this to get node of tree by path with '/' terminator
397
    //
398
    //SOURCE: http://php.net/manual/en/function.xml-parse.php
399
    private function get_value_by_path($__xml_tree, $__tag_path)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
400
    {
401
        $tmp_arr =& $__xml_tree;
402
        $tag_path = explode('/', $__tag_path);
403
        foreach ($tag_path as $tag_name) {
404
            $res = false;
405
            foreach ($tmp_arr as $key => $node) {
406
                if (is_int($key) && $node['name'] == $tag_name) {
407
                    $tmp_arr = $node;
408
                    $res = true;
409
                    break;
410
                }
411
            }
412
            if (!$res) {
413
                return false;
414
            }
415
        }
416
        return $tmp_arr;
417
    }
418
419
    /**
420
     *
421
     * @param String $serializedData
422
     *
423
     * @return Array
424
     */
425
    public function safelyUnserialize($serializedData)
426
    {
427
        return unserialize(base64_decode($serializedData));
428
        //this code needs checking.
429
        try {
0 ignored issues
show
try { $fixed = unser... }, $serializedData); } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
430
            $fixed = unserialize(base64_decode($serializedData));
431
            if (is_array($fixed)) {
432
                return $fixed;
433
            } else {
434
                return unserialize($serializedData);
435
            }
436
        } catch (Exception $e) {
437
            $fixed = preg_replace_callback(
438
                '!s:(\d+):"(.*?)";!',
439
                function ($match) {
440
                    return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
441
                },
442
                $serializedData
443
            );
444
        }
445
        return $fixed;
446
    }
447
448
    /**
449
     *
450
     * @param Array $dataAsArray
451
     *
452
     * @return String
453
     *
454
     */
455
    public function safelySerialize($dataAsArray)
456
    {
457
        return base64_encode(serialize($dataAsArray));
458
    }
459
}
460