2020-03-23 15:12:07 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ModifiedFile
|
|
|
|
*/
|
|
|
|
class ModifiedFile
|
|
|
|
{
|
|
|
|
/** @var string */
|
|
|
|
const ADDED = 'A';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const DELETED = 'D';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const MODIFIED = 'M';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const RENAMED = 'R';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const MODULE_ID = 'intaro.retailcrm';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const DESCRIPTION = 'description.ru';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
const VERSION = 'install/version.php';
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
protected $filename;
|
|
|
|
|
2021-11-16 10:48:26 +03:00
|
|
|
/** @var string */
|
|
|
|
protected $oldFilename;
|
|
|
|
|
2020-03-23 15:12:07 +03:00
|
|
|
/** @var string */
|
|
|
|
protected $modificator;
|
|
|
|
|
2021-11-16 10:48:26 +03:00
|
|
|
/** @var int */
|
|
|
|
protected $percent;
|
|
|
|
|
2020-03-23 15:12:07 +03:00
|
|
|
/**
|
|
|
|
* ModifiedFile constructor.
|
2021-11-16 10:48:26 +03:00
|
|
|
* @param string $source
|
2020-03-23 15:12:07 +03:00
|
|
|
*/
|
2021-11-16 10:48:26 +03:00
|
|
|
public function __construct($source)
|
2020-03-23 15:12:07 +03:00
|
|
|
{
|
2021-11-16 10:48:26 +03:00
|
|
|
$params = explode("\t", trim($source));
|
|
|
|
|
|
|
|
$this->filename = $params[1];
|
|
|
|
$this->modificator = $params[0][0];
|
|
|
|
|
|
|
|
if (strlen($params[0]) > 1) {
|
|
|
|
$this->percent = (int) substr($params[0], 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($params) >= 3) {
|
|
|
|
$this->filename = $params[2];
|
|
|
|
$this->oldFilename = $params[1];
|
|
|
|
}
|
2020-03-23 15:12:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isAdded()
|
|
|
|
{
|
|
|
|
return $this->modificator === static::ADDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isDeleted()
|
|
|
|
{
|
|
|
|
return $this->modificator === static::DELETED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isModified()
|
|
|
|
{
|
|
|
|
return $this->modificator === static::MODIFIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isRenamed()
|
|
|
|
{
|
|
|
|
return $this->modificator === static::RENAMED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isModuleFile()
|
|
|
|
{
|
|
|
|
return strpos($this->filename, static::MODULE_ID) === 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getFilename()
|
|
|
|
{
|
|
|
|
return $this->filename;
|
|
|
|
}
|
2021-11-16 10:48:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOldFilename()
|
|
|
|
{
|
|
|
|
return $this->oldFilename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getPercent()
|
|
|
|
{
|
|
|
|
return $this->percent;
|
|
|
|
}
|
2020-03-23 15:12:07 +03:00
|
|
|
}
|