Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Laravel 5.3 Package Shift #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"require": {
"php": ">=5.5.9",
"php": ">=5.6.4",
"illuminate/support": "~5",
"simplepie/simplepie": "~1.4"
},
Expand All @@ -18,4 +18,4 @@
"Awjudd\\FeedReader\\": "src/"
}
}
}
}
2 changes: 1 addition & 1 deletion config/rss-feed-reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
'order-by-date' => false,
],
],
];
];
2 changes: 1 addition & 1 deletion src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ protected static function getFacadeAccessor()
{
return 'rss-feed-reader';
}
}
}
31 changes: 13 additions & 18 deletions src/FeedReader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace Awjudd\FeedReader;

/**
* @Author: Andrew Judd
* @Date: 2015-03-22 22:16:19
Expand All @@ -13,7 +14,7 @@ class FeedReader
{
/**
* Used to parse an RSS feed.
*
*
* @return \SimplePie
*/
public function read($url, $configuration = 'default')
Expand All @@ -22,15 +23,12 @@ public function read($url, $configuration = 'default')
$sp = new SimplePie();

// Configure it
if(($cache = $this->setup_cache_directory($configuration)) !== false)
{
// Enable caching, and set the folder
if (($cache = $this->setup_cache_directory($configuration)) !== false) {
// Enable caching, and set the folder
$sp->enable_cache(true);
$sp->set_cache_location($cache);
$sp->set_cache_duration($this->read_config($configuration, 'cache.duration', 3600));
}
else
{
} else {
// Disable caching
$sp->enable_cache(false);
}
Expand All @@ -53,7 +51,7 @@ public function read($url, $configuration = 'default')

/**
* Used in order to setup the cache directory for future use.
*
*
* @param string The configuration to use
* @return string The folder that is being cached to
*/
Expand All @@ -63,26 +61,23 @@ private function setup_cache_directory($configuration)
$cache_enabled = $this->read_config($configuration, 'cache.enabled', false);

// Is caching enabled?
if(!$cache_enabled)
{
// It is disabled, so skip it
if (!$cache_enabled) {
// It is disabled, so skip it
return false;
}

// Grab the cache location
$cache_location = storage_path($this->read_config($configuration, 'cache.location', 'rss-feeds'));

// Is the last character a slash?
if(substr($cache_location, -1) != DIRECTORY_SEPARATOR)
{
// Add in the slash at the end
if (substr($cache_location, -1) != DIRECTORY_SEPARATOR) {
// Add in the slash at the end
$cache_location .= DIRECTORY_SEPARATOR;
}

// Check if the folder is available
if(!file_exists($cache_location))
{
// It didn't, so make it
if (!file_exists($cache_location)) {
// It didn't, so make it
mkdir($cache_location, 0777);

// Also add in a .gitignore file
Expand All @@ -95,7 +90,7 @@ private function setup_cache_directory($configuration)
/**
* Used internally in order to retrieve a sepcific value from the configuration
* file.
*
*
* @param string $configuration The name of the configuration to use
* @param string $name The name of the value in the configuration file to retrieve
* @param mixed $default The default value
Expand Down
3 changes: 1 addition & 2 deletions src/FeedReaderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ private function setupProcessor()
{
$this->app->singleton(FeedReader::class);
}

}
}