Sane argument names in the IO Factory
This commit is contained in:
parent
06f7d3c8bd
commit
7e4248d67f
|
|
@ -167,9 +167,9 @@ abstract class DefinedName
|
||||||
/**
|
/**
|
||||||
* Set worksheet.
|
* Set worksheet.
|
||||||
*/
|
*/
|
||||||
public function setWorksheet(?Worksheet $value): self
|
public function setWorksheet(?Worksheet $worksheet): self
|
||||||
{
|
{
|
||||||
$this->worksheet = $value;
|
$this->worksheet = $worksheet;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -203,10 +203,10 @@ abstract class DefinedName
|
||||||
/**
|
/**
|
||||||
* Set localOnly.
|
* Set localOnly.
|
||||||
*/
|
*/
|
||||||
public function setLocalOnly(bool $value): self
|
public function setLocalOnly(bool $localScope): self
|
||||||
{
|
{
|
||||||
$this->localOnly = $value;
|
$this->localOnly = $localScope;
|
||||||
$this->scope = $value ? $this->worksheet : null;
|
$this->scope = $localScope ? $this->worksheet : null;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -222,10 +222,10 @@ abstract class DefinedName
|
||||||
/**
|
/**
|
||||||
* Set scope.
|
* Set scope.
|
||||||
*/
|
*/
|
||||||
public function setScope(?Worksheet $value): self
|
public function setScope(?Worksheet $worksheet): self
|
||||||
{
|
{
|
||||||
$this->scope = $value;
|
$this->scope = $worksheet;
|
||||||
$this->localOnly = $value !== null;
|
$this->localOnly = $worksheet !== null;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -241,9 +241,9 @@ abstract class DefinedName
|
||||||
/**
|
/**
|
||||||
* Resolve a named range to a regular cell range or formula.
|
* Resolve a named range to a regular cell range or formula.
|
||||||
*/
|
*/
|
||||||
public static function resolveName(string $pDefinedName, Worksheet $pSheet): ?self
|
public static function resolveName(string $definedName, Worksheet $worksheet): ?self
|
||||||
{
|
{
|
||||||
return $pSheet->getParent()->getDefinedName($pDefinedName, $pSheet);
|
return $worksheet->getParent()->getDefinedName($definedName, $worksheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -21,29 +21,29 @@ class HashTable
|
||||||
/**
|
/**
|
||||||
* Create a new \PhpOffice\PhpSpreadsheet\HashTable.
|
* Create a new \PhpOffice\PhpSpreadsheet\HashTable.
|
||||||
*
|
*
|
||||||
* @param IComparable[] $pSource Optional source array to create HashTable from
|
* @param IComparable[] $source Optional source array to create HashTable from
|
||||||
*/
|
*/
|
||||||
public function __construct($pSource = null)
|
public function __construct($source = null)
|
||||||
{
|
{
|
||||||
if ($pSource !== null) {
|
if ($source !== null) {
|
||||||
// Create HashTable
|
// Create HashTable
|
||||||
$this->addFromSource($pSource);
|
$this->addFromSource($source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add HashTable items from source.
|
* Add HashTable items from source.
|
||||||
*
|
*
|
||||||
* @param IComparable[] $pSource Source array to create HashTable from
|
* @param IComparable[] $source Source array to create HashTable from
|
||||||
*/
|
*/
|
||||||
public function addFromSource(?array $pSource = null): void
|
public function addFromSource(?array $source = null): void
|
||||||
{
|
{
|
||||||
// Check if an array was passed
|
// Check if an array was passed
|
||||||
if ($pSource == null) {
|
if ($source == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pSource as $item) {
|
foreach ($source as $item) {
|
||||||
$this->add($item);
|
$this->add($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,13 +51,13 @@ class HashTable
|
||||||
/**
|
/**
|
||||||
* Add HashTable item.
|
* Add HashTable item.
|
||||||
*
|
*
|
||||||
* @param IComparable $pSource Item to add
|
* @param IComparable $source Item to add
|
||||||
*/
|
*/
|
||||||
public function add(IComparable $pSource): void
|
public function add(IComparable $source): void
|
||||||
{
|
{
|
||||||
$hash = $pSource->getHashCode();
|
$hash = $source->getHashCode();
|
||||||
if (!isset($this->items[$hash])) {
|
if (!isset($this->items[$hash])) {
|
||||||
$this->items[$hash] = $pSource;
|
$this->items[$hash] = $source;
|
||||||
$this->keyMap[count($this->items) - 1] = $hash;
|
$this->keyMap[count($this->items) - 1] = $hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -65,11 +65,11 @@ class HashTable
|
||||||
/**
|
/**
|
||||||
* Remove HashTable item.
|
* Remove HashTable item.
|
||||||
*
|
*
|
||||||
* @param IComparable $pSource Item to remove
|
* @param IComparable $source Item to remove
|
||||||
*/
|
*/
|
||||||
public function remove(IComparable $pSource): void
|
public function remove(IComparable $source): void
|
||||||
{
|
{
|
||||||
$hash = $pSource->getHashCode();
|
$hash = $source->getHashCode();
|
||||||
if (isset($this->items[$hash])) {
|
if (isset($this->items[$hash])) {
|
||||||
unset($this->items[$hash]);
|
unset($this->items[$hash]);
|
||||||
|
|
||||||
|
|
@ -109,26 +109,26 @@ class HashTable
|
||||||
/**
|
/**
|
||||||
* Get index for hash code.
|
* Get index for hash code.
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $hashCode
|
||||||
*
|
*
|
||||||
* @return int Index
|
* @return int Index
|
||||||
*/
|
*/
|
||||||
public function getIndexForHashCode($pHashCode)
|
public function getIndexForHashCode($hashCode)
|
||||||
{
|
{
|
||||||
return array_search($pHashCode, $this->keyMap);
|
return array_search($hashCode, $this->keyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get by index.
|
* Get by index.
|
||||||
*
|
*
|
||||||
* @param int $pIndex
|
* @param int $index
|
||||||
*
|
*
|
||||||
* @return IComparable
|
* @return IComparable
|
||||||
*/
|
*/
|
||||||
public function getByIndex($pIndex)
|
public function getByIndex($index)
|
||||||
{
|
{
|
||||||
if (isset($this->keyMap[$pIndex])) {
|
if (isset($this->keyMap[$index])) {
|
||||||
return $this->getByHashCode($this->keyMap[$pIndex]);
|
return $this->getByHashCode($this->keyMap[$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -137,14 +137,14 @@ class HashTable
|
||||||
/**
|
/**
|
||||||
* Get by hashcode.
|
* Get by hashcode.
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $hashCode
|
||||||
*
|
*
|
||||||
* @return IComparable
|
* @return IComparable
|
||||||
*/
|
*/
|
||||||
public function getByHashCode($pHashCode)
|
public function getByHashCode($hashCode)
|
||||||
{
|
{
|
||||||
if (isset($this->items[$pHashCode])) {
|
if (isset($this->items[$hashCode])) {
|
||||||
return $this->items[$pHashCode];
|
return $this->items[$hashCode];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -69,19 +69,19 @@ abstract class IOFactory
|
||||||
/**
|
/**
|
||||||
* Loads Spreadsheet from file using automatic IReader resolution.
|
* Loads Spreadsheet from file using automatic IReader resolution.
|
||||||
*/
|
*/
|
||||||
public static function load(string $pFilename): Spreadsheet
|
public static function load(string $filename): Spreadsheet
|
||||||
{
|
{
|
||||||
$reader = self::createReaderForFile($pFilename);
|
$reader = self::createReaderForFile($filename);
|
||||||
|
|
||||||
return $reader->load($pFilename);
|
return $reader->load($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify file type using automatic IReader resolution.
|
* Identify file type using automatic IReader resolution.
|
||||||
*/
|
*/
|
||||||
public static function identify(string $pFilename): string
|
public static function identify(string $filename): string
|
||||||
{
|
{
|
||||||
$reader = self::createReaderForFile($pFilename);
|
$reader = self::createReaderForFile($filename);
|
||||||
$className = get_class($reader);
|
$className = get_class($reader);
|
||||||
$classType = explode('\\', $className);
|
$classType = explode('\\', $className);
|
||||||
unset($reader);
|
unset($reader);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue