summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php')
-rw-r--r--vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php93
1 files changed, 44 insertions, 49 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php
index 6347054bb..34e21dc19 100644
--- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php
+++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php
@@ -3,30 +3,26 @@
namespace PicoFeed\Filter;
use DOMXpath;
-
use PicoFeed\Parser\XmlParser;
use PicoFeed\Config\Config;
/**
- * Tag Filter class
+ * Tag Filter class.
*
* @author Frederic Guillot
- * @package Filter
*/
class Tag
{
/**
- * Config object
+ * Config object.
*
- * @access private
* @var \PicoFeed\Config\Config
*/
private $config;
/**
- * Tags blacklist (Xpath expressions)
+ * Tags blacklist (Xpath expressions).
*
- * @access private
* @var array
*/
private $tag_blacklist = array(
@@ -35,9 +31,8 @@ class Tag
);
/**
- * Tags whitelist
+ * Tags whitelist.
*
- * @access private
* @var array
*/
private $tag_whitelist = array(
@@ -87,24 +82,24 @@ class Tag
}
/**
- * Check if the tag is allowed and is not a pixel tracker
+ * Check if the tag is allowed and is not a pixel tracker.
+ *
+ * @param string $tag Tag name
+ * @param array $attributes Attributes dictionary
*
- * @access public
- * @param string $tag Tag name
- * @param array $attributes Attributes dictionary
- * @return boolean
+ * @return bool
*/
public function isAllowed($tag, array $attributes)
{
- return $this->isAllowedTag($tag) && ! $this->isPixelTracker($tag, $attributes);
+ return $this->isAllowedTag($tag) && !$this->isPixelTracker($tag, $attributes);
}
/**
- * Return the HTML opening tag
+ * Return the HTML opening tag.
+ *
+ * @param string $tag Tag name
+ * @param string $attributes Attributes converted in html
*
- * @access public
- * @param string $tag Tag name
- * @param string $attributes Attributes converted in html
* @return string
*/
public function openHtmlTag($tag, $attributes = '')
@@ -113,10 +108,10 @@ class Tag
}
/**
- * Return the HTML closing tag
+ * Return the HTML closing tag.
+ *
+ * @param string $tag Tag name
*
- * @access public
- * @param string $tag Tag name
* @return string
*/
public function closeHtmlTag($tag)
@@ -125,11 +120,11 @@ class Tag
}
/**
- * Return true is the tag is self-closing
+ * Return true is the tag is self-closing.
*
- * @access public
- * @param string $tag Tag name
- * @return boolean
+ * @param string $tag Tag name
+ *
+ * @return bool
*/
public function isSelfClosingTag($tag)
{
@@ -137,11 +132,11 @@ class Tag
}
/**
- * Check if a tag is on the whitelist
+ * Check if a tag is on the whitelist.
+ *
+ * @param string $tag Tag name
*
- * @access public
- * @param string $tag Tag name
- * @return boolean
+ * @return bool
*/
public function isAllowedTag($tag)
{
@@ -152,12 +147,12 @@ class Tag
}
/**
- * Detect if an image tag is a pixel tracker
+ * Detect if an image tag is a pixel tracker.
+ *
+ * @param string $tag Tag name
+ * @param array $attributes Tag attributes
*
- * @access public
- * @param string $tag Tag name
- * @param array $attributes Tag attributes
- * @return boolean
+ * @return bool
*/
public function isPixelTracker($tag, array $attributes)
{
@@ -167,10 +162,10 @@ class Tag
}
/**
- * Remove script tags
+ * Remove script tags.
+ *
+ * @param string $data Input data
*
- * @access public
- * @param string $data Input data
* @return string
*/
public function removeBlacklistedTags($data)
@@ -192,12 +187,11 @@ class Tag
return $dom->saveXML();
}
-
/**
- * Remove empty tags
+ * Remove empty tags.
+ *
+ * @param string $data Input data
*
- * @access public
- * @param string $data Input data
* @return string
*/
public function removeEmptyTags($data)
@@ -206,27 +200,28 @@ class Tag
}
/**
- * Replace <br/><br/> by only one
+ * Replace <br/><br/> by only one.
+ *
+ * @param string $data Input data
*
- * @access public
- * @param string $data Input data
* @return string
*/
public function removeMultipleBreakTags($data)
{
- return preg_replace("/(<br\s*\/?>\s*)+/", "<br/>", $data);
+ return preg_replace("/(<br\s*\/?>\s*)+/", '<br/>', $data);
}
/**
- * Set whitelisted tags adn attributes for each tag
+ * Set whitelisted tags adn attributes for each tag.
+ *
+ * @param array $values List of tags: ['video' => ['src', 'cover'], 'img' => ['src']]
*
- * @access public
- * @param array $values List of tags: ['video' => ['src', 'cover'], 'img' => ['src']]
* @return Tag
*/
public function setWhitelistedTags(array $values)
{
$this->tag_whitelist = $values ?: $this->tag_whitelist;
+
return $this;
}
}