-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from GrahamCampbell/chaining
Chaining
- Loading branch information
Showing
7 changed files
with
42 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,23 @@ | |
* Class Facade. | ||
* | ||
* This is the main point of entry for using Factory Muffin. | ||
* This class dynamically proxies static method calls to the underlying factory instance. | ||
* This class dynamically proxies static method calls to | ||
* the underlying factory instance. | ||
* | ||
* @see League\FactoryMuffin\Factory | ||
* | ||
* @method static void setSaveMethod(string $method) Set the method we use when saving objects. | ||
* @method static void setDeleteMethod(string $method) Set the method we use when deleting objects. | ||
* @method static Factory setSaveMethod(string $method) Set the method we use when saving objects. | ||
* @method static Factory setDeleteMethod(string $method) Set the method we use when deleting objects. | ||
* @method static object[] seed(int $times, string $model, array $attr = array()) Returns multiple versions of an object. | ||
* @method static object create(string $model, array $attr = array()) Creates and saves in db an instance of the model. | ||
* @method static object[] saved() Return an array of saved objects. | ||
* @method static bool isSaved(object $object) Is the object saved? | ||
* @method static void deleteSaved() Call the delete method on any saved objects. | ||
* @method static Factory deleteSaved() Call the delete method on any saved objects. | ||
* @method static object instance(string $model, array $attr = array()) Return an instance of the model. | ||
* @method static array attributesFor(object $object, array $attr = array()) Returns the mock attributes for the model. | ||
* @method static void define(string $model, array $definition = array()) Define a new model factory. | ||
* @method static Factory define(string $model, array $definition = array()) Define a new model factory. | ||
* @method static string|object generateAttr(string $kind, object $object = null) Generate the attributes. | ||
* @method static void loadFactories(string|string[] $paths) Load the specified factories. | ||
* @method static Factory loadFactories(string|string[] $paths) Load the specified factories. | ||
* | ||
* @package League\FactoryMuffin | ||
* @author Zizaco <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,9 @@ | |
/** | ||
* Class Factory. | ||
* | ||
* This class is not intended to be used directly. | ||
* Please use the provided facade. | ||
* This class is not intended to be used directly. Please | ||
* use the provided facade. This class may be used a result | ||
* of method chaining after initially using the facade. | ||
* | ||
* @package League\FactoryMuffin | ||
* @author Zizaco <[email protected]> | ||
|
@@ -77,38 +78,44 @@ class Factory | |
* | ||
* @param string $local | ||
* | ||
* @return void | ||
* @return $this | ||
*/ | ||
public function setFakerLocale($local) | ||
{ | ||
$this->fakerLocale = $local; | ||
|
||
// The faker class must be instantiated again with a new the new locale | ||
$this->faker = null; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the method we use when saving objects. | ||
* | ||
* @param string $method | ||
* | ||
* @return void | ||
* @return $this | ||
*/ | ||
public function setSaveMethod($method) | ||
{ | ||
$this->saveMethod = $method; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the method we use when deleting objects. | ||
* | ||
* @param string $method | ||
* | ||
* @return void | ||
* @return $this | ||
*/ | ||
public function setDeleteMethod($method) | ||
{ | ||
$this->deleteMethod = $method; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
|
@@ -233,7 +240,7 @@ public function isSaved($object) | |
* | ||
* @throws \League\FactoryMuffin\Exceptions\DeletingFailedException | ||
* | ||
* @return void | ||
* return $this | ||
*/ | ||
public function deleteSaved() | ||
{ | ||
|
@@ -255,6 +262,8 @@ public function deleteSaved() | |
if ($exceptions) { | ||
throw new DeletingFailedException($exceptions); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
|
@@ -336,11 +345,13 @@ private function getFactoryAttrs($model) | |
* @param string $model Model class name. | ||
* @param array $definition Array with definition of attributes. | ||
* | ||
* @return void | ||
* @return $this | ||
*/ | ||
public function define($model, array $definition = array()) | ||
{ | ||
$this->factories[$model] = $definition; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
|
@@ -385,7 +396,7 @@ private function getFaker() | |
* | ||
* @throws \League\FactoryMuffin\Exceptions\DirectoryNotFoundException | ||
* | ||
* @return void | ||
* @return $this | ||
*/ | ||
public function loadFactories($paths) | ||
{ | ||
|
@@ -396,6 +407,8 @@ public function loadFactories($paths) | |
|
||
$this->loadDirectory($path); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters