Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added more docblocks; added getConfig and setConfig to Base class

  • Loading branch information...
commit c09e9544fc2a799ef373476db0dab7bb75d96624 1 parent 9933805
José Pedro Saraiva authored
35 lib/Base/Base.php
View
@@ -17,6 +17,11 @@
protected $_config;
+ /**
+ * Class constructor
+ *
+ * @param Config|array
+ */
public function __construct( $config )
{
if ($config instanceof Config) {
@@ -27,11 +32,37 @@ public function __construct( $config )
} // __construct }}}
/**
+ * Get config class instance
+ *
+ * @return Config
+ */
+ public function getConfig()
+ {
+ return $this->_config;
+ } // getConfig }}}
+
+ /**
+ * Set config class instance
+ *
+ * @param $config Config
+ * @throws \InvalidArgumentException
+ * @return Base
+ */
+ public function setConfig( $config )
+ {
+ if (! $config instanceof Config) {
+ throw new \InvalidArgumentException( '$config must be an instance of Config' );
+ }
+ $this->_config = $config;
+ return $this;
+ } // setConfig }}}
+
+ /**
* Enter description here ...
*
* @param string $str
- * @param string $level
- * @param string|null $logfile
+ * @param string $level optional
+ * @param string|null $logfile optional
* @return bool
*/
public function log( $str, $level = Log::LEVEL_DEBUG, $logfile = null )
25 lib/HTMLPageExcerpt.php
View
@@ -235,8 +235,6 @@ public function get( $fields = '*', $flatten = false )
/**
* Enter description here ...
- *
- * @return void
*/
public function reset()
{
@@ -255,11 +253,10 @@ public function reset()
* Enter description here ...
*
* @param string $html
- * @return void
*/
protected function _loadDocument( $html )
{
- $config = $this->_config;
+ $config = $this->getConfig();
$dom = new \DOMDocument();
$dom->preserveWhitespace = false;
@@ -282,12 +279,12 @@ protected function _loadDocument( $html )
/**
* Enter description here ...
*
- * @param DOMDocument $dom
+ * @param \DOMDocument $dom
* @return string
*/
protected function _getEncoding( &$dom )
{
- $config = $this->_config;
+ $config = $this->getConfig();
// get encoding from announced http content type header, if any
if (! empty( $this->url->encoding )) {
@@ -370,6 +367,7 @@ protected function _find( $what )
{
$what = strtolower( $what );
if (in_array( $what, $this->_fields )) {
+ // return if already cached
if (isset( $this->{$what} ) && $this->{$what} !== null) {
return $this->{$what};
}
@@ -386,7 +384,8 @@ protected function _find( $what )
*/
protected function _findTitle()
{
- $config = $this->_config;
+ $config = $this->getConfig();
+
$title = null;
$SEO_ignFilters = $config->get( $config::TITLE_SEO_TAGS_IGNORE_FILTERS );
@@ -442,7 +441,8 @@ protected function _findTitle()
*/
protected function _findExcerpt()
{
- $config = $this->_config;
+ $config = $this->getConfig();
+
$excerpt = null;
$SEO_ignFilters = $config->get( $config::EXCERPT_SEO_TAGS_IGNORE_FILTERS );
@@ -520,7 +520,8 @@ protected function _findExcerpt()
*/
protected function _findThumbs()
{
- $config = $this->_config;
+ $config = $this->getConfig();
+
$SEO_ignFilters = $config->get( $config::THUMBS_SEO_TAGS_IGNORE_FILTERS );
$thumbnails = array();
$tries = 0;
@@ -657,9 +658,9 @@ protected function _findFavicon()
*/
protected function _isUrlBlacklisted( $type, $url )
{
- $config = $this->_config;
- $type = strtoupper( $type );
+ $config = $this->getConfig();
+ $type = strtoupper( $type );
$constantName = get_class( $config ) . "::{$type}_URL_BLACKLIST";
$blacklistPattern = $config->get( constant( $constantName ) );
if (empty( $blacklistPattern )) {
@@ -679,7 +680,7 @@ protected function _isUrlBlacklisted( $type, $url )
*/
protected function _getFilterOpts( $type )
{
- $config = $this->_config;
+ $config = $this->getConfig();
switch ($type) {
case static::FIELD_TITLE:
2  lib/Object/Text/Text.php
View
@@ -82,7 +82,7 @@ public function matches( $criteria )
*/
public function sanitize( $str )
{
- $config = $this->_config;
+ $config = $this->getConfig();
//Util::hexDump( $str );
5 lib/Object/Url/Url.php
View
@@ -196,7 +196,8 @@ public function fetch()
throw new \InvalidArgumentException( "Url '{$this->url}' is not a valid absolute url" );
}
- $config = $this->_config;
+ $config = $this->getConfig();
+
$opts = array(
$config::FETCHER_TIMEOUT => $config->get( $config::FETCHER_TIMEOUT ),
$config::FETCHER_USER_AGENT => $config->get( $config::FETCHER_USER_AGENT ),
@@ -229,7 +230,7 @@ public function fetch()
curl_setopt( $this->_curl, CURLOPT_REFERER, $this->url );
}
-// curl_setopt( $this->_curl, CURLOPT_VERBOSE, true );
+ //curl_setopt( $this->_curl, CURLOPT_VERBOSE, true );
$logstr = sprintf(
'-- fetching url %s, timeout: %s, ua: %s, follow_loc: %s, max_redirs: %s, proxy: %s, fake_ref: %s',
0  tests.php → lib/Test/tests.php
View
File renamed without changes
4 lib/Util/Util.php
View
@@ -120,8 +120,8 @@ public static function DOMinnerHTML( $element )
/**
* Enter description here ...
*
- * @param string $data
- * @param string $newline
+ * @param string $data
+ * @param string $newline
*/
public static function hexDump( $data, $newline = "\n" )
{
Please sign in to comment.
Something went wrong with that request. Please try again.