for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JeroenG\LaravelPhotoGallery\Traits;
use JeroenG\LaravelPhotoGallery\Entities as Entity;
trait Creators
{
public function createAlbum($data = null, $add = true)
$faker = \Faker\Factory::create();
$album = new Entity\Album();
$metadata = [
'id' => $faker->unique()->randomDigitNotNull(),
'name' => $faker->name,
'description' => $faker->sentence(3)
];
if(!is_null($data)) {
foreach ($data as $key => $value) {
$metadata[$key] = $value;
}
$album->map($metadata);
if($add) {
$this->albums->add($album);
albums
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;
return $album;
public function createPhoto($data = null, $add = true)
$photo = new Entity\Photo();
'description' => $faker->sentence(3),
'file' => $faker->imageUrl(640, 480),
'size' => '640x480',
'album_id' => $faker->unique()->randomDigitNotNull()
$photo->map($metadata);
$this->photos->add($photo);
photos
return $photo;
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: