2015-06-01 11:41:18 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Support;
|
|
|
|
|
|
|
|
|
2015-06-02 10:44:50 -05:00
|
|
|
use Auth;
|
2015-06-01 11:41:18 -05:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
|
|
|
use Illuminate\Support\Collection;
|
2015-06-02 10:44:50 -05:00
|
|
|
use Preferences;
|
2015-06-01 11:41:18 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ChartProperties
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Support
|
|
|
|
*/
|
|
|
|
class ChartProperties
|
|
|
|
{
|
|
|
|
|
|
|
|
/** @var Collection */
|
|
|
|
protected $properties;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->properties = new Collection;
|
2015-06-02 10:44:50 -05:00
|
|
|
$this->addProperty(Auth::user()->id);
|
|
|
|
$this->addProperty(Preferences::lastActivity());
|
2015-06-01 11:41:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $property
|
|
|
|
*/
|
|
|
|
public function addProperty($property)
|
|
|
|
{
|
|
|
|
$this->properties->push($property);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function md5()
|
|
|
|
{
|
|
|
|
$string = '';
|
2015-06-02 10:44:50 -05:00
|
|
|
//Log::debug('--- building string ---');
|
2015-06-01 11:41:18 -05:00
|
|
|
foreach ($this->properties as $property) {
|
|
|
|
|
|
|
|
if ($property instanceof Collection || $property instanceof EloquentCollection) {
|
|
|
|
$string .= print_r($property->toArray(), true);
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('added collection (size=' . $property->count() . ')');
|
2015-06-01 11:41:18 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($property instanceof Carbon) {
|
|
|
|
$string .= $property->toRfc3339String();
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('Added time: ' . $property->toRfc3339String());
|
2015-06-01 11:41:18 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (is_object($property)) {
|
|
|
|
$string .= $property->__toString();
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('Added object of class ' . get_class($property));
|
2015-06-01 11:41:18 -05:00
|
|
|
}
|
|
|
|
if (is_array($property)) {
|
|
|
|
$string .= print_r($property, true);
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('Added array (size=' . count($property) . ')');
|
2015-06-01 11:41:18 -05:00
|
|
|
}
|
|
|
|
$string .= (string)$property;
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('Added cast to string: ' . $property);
|
2015-06-01 11:41:18 -05:00
|
|
|
}
|
|
|
|
|
2015-06-02 10:44:50 -05:00
|
|
|
// Log::debug('--- done building string ---');
|
|
|
|
|
2015-06-01 11:41:18 -05:00
|
|
|
return md5($string);
|
|
|
|
}
|
|
|
|
}
|