Skip to content

Commit

Permalink
adapt code to meet contribution guidelines
Browse files Browse the repository at this point in the history
- private modifiers for new variables
- php7 type hinting
  • Loading branch information
ulopezrojo committed Nov 5, 2017
1 parent 64bdba6 commit 2cb3210
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Download extends ImportController
/**
* @var \Magento\ImportExport\Model\Import\SampleFileProvider
*/
protected $sampleFileProvider;
private $sampleFileProvider;

/**
* Constructor
Expand Down
22 changes: 10 additions & 12 deletions app/code/Magento/ImportExport/Model/Import/SampleFileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

/**
* Import Sample File Provider model
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class SampleFileProvider
{
/**
* Associate an import entity to its module, e.g ['entity_name' => 'module_name']
* @var array
*/
private $samples;
Expand All @@ -32,7 +31,6 @@ class SampleFileProvider
private $readFactory;

/**
* SampleFilePathProvider constructor.
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
* @param ComponentRegistrar $componentRegistrar
* @param array $samples
Expand All @@ -50,11 +48,11 @@ public function __construct(
/**
* Returns the Size for the given file associated to an Import entity
*
* @param $fileName
* @param string $fileName
* @throws NoSuchEntityException
* @return int
*/
public function getSize(string $entityName)
public function getSize(string $entityName): int
{
$directoryRead = $this->getDirectoryRead($entityName);
$filePath = $this->getPath($entityName);
Expand All @@ -71,7 +69,7 @@ public function getSize(string $entityName)
* @throws NoSuchEntityException
* @return string
*/
public function getFileContents(string $entityName)
public function getFileContents(string $entityName): string
{
$directoryRead = $this->getDirectoryRead($entityName);
$filePath = $this->getPath($entityName);
Expand All @@ -81,10 +79,10 @@ public function getFileContents(string $entityName)

/**
* @param $entityName
* @return string
* @return string $entityName
* @throws NoSuchEntityException
*/
private function getPath($entityName)
private function getPath(string $entityName): string
{
$directoryRead = $this->getDirectoryRead($entityName);
$moduleName = $this->getModuleName($entityName);
Expand All @@ -101,10 +99,10 @@ private function getPath($entityName)
}

/**
* @param $fileName
* @param string $entityName
* @return ReadInterface
*/
private function getDirectoryRead($entityName): ReadInterface
private function getDirectoryRead(string $entityName): ReadInterface
{
$moduleName = $this->getModuleName($entityName);
$moduleDir = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
Expand All @@ -114,11 +112,11 @@ private function getDirectoryRead($entityName): ReadInterface
}

/**
* @param $entityName
* @param string $entityName
* @return string
* @throws NoSuchEntityException
*/
private function getModuleName($entityName): string
private function getModuleName(string $entityName): string
{
if (!isset($this->samples[$entityName])) {
throw new NoSuchEntityException();
Expand Down

0 comments on commit 2cb3210

Please sign in to comment.