for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ArgentCrusade\Selectel\CloudStorage\Traits;
use ArgentCrusade\Selectel\CloudStorage\Collections\Collection;
use ArgentCrusade\Selectel\CloudStorage\File;
trait FilesTransformer
{
/**
* Transforms file array to instance of File object.
*
* @param array $file File array.
* @return \ArgentCrusade\Selectel\CloudStorage\Contracts\FileContract
*/
public function getFileFromArray(array $file)
return new File($this->api, $this->containerName, $file);
api
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
containerName
}
* Transforms Collection of file arrays (or plain array) to Collection of File objects.
* Warning: converting a lot of files to `File` instances may result in performance loss.
* @param array|\ArgentCrusade\Selectel\CloudStorage\Collections\Collection $files
* @return \ArgentCrusade\Selectel\CloudStorage\Collections\Collection
public function getFilesCollectionFromArrays($files)
$collection = new Collection();
foreach ($files as $file) {
$collection[] = $this->getFileFromArray($file);
return $collection;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: