Skip to content

Commit

Permalink
change api syntax in favour of "create" over "build"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Milloy committed Feb 10, 2019
1 parent 2eaaf6f commit d9fbb34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CHANGELOG

## v0.1.4

Add ability to export tempfile

## v.0.1.0

Initial deploy
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Install with composer using `composer require itsnubix/nowcal`
```php
use NowCal\NowCal;

$event = NowCal::build(['start' => 'October 5, 2019 6:03PM']))
$event = NowCal::create(['start' => 'October 5, 2019 6:03PM']))
->summary('Daft Punk is playing')
->location('My House');
```
Expand Down Expand Up @@ -45,7 +45,7 @@ $props = [
];

// Creates a NowCal instance
$nowcal = new NowCal($props); // or NowCal::build($props);
$nowcal = new NowCal($props); // or NowCal::create($props);

// Exports a raw output array
$nowcal->raw; // or NowCal::raw($props)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itsnubix/nowcal",
"version": "0.1.4",
"version": "0.1.5",
"description": "A modern PHP library for generating iCalendar v2.0 events",
"keywords": [
"icalendar",
Expand Down
20 changes: 17 additions & 3 deletions src/NowCal/Traits/HasStaticAccessors.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@

trait HasStaticAccessors
{
/**
* Pass the props into the class and create a new instance.
*
* @param array $props
*
* @return \NowCal\NowCal
*/
public static function create(array $props = [])
{
return new self($props);
}

/**
* Pass the props into the class and build it.
*
* @param array $props
*
* @deprecated 1.0.0 Prefer "create" syntax
*
* @return \NowCal\NowCal
*/
public static function build(array $props = [])
Expand All @@ -25,7 +39,7 @@ public static function build(array $props = [])
*/
public static function raw(array $props = []): array
{
return self::build($props)->raw;
return self::create($props)->raw;
}

/**
Expand All @@ -37,7 +51,7 @@ public static function raw(array $props = []): array
*/
public static function plain(array $props = []): string
{
return self::build($props)->plain;
return self::create($props)->plain;
}

/**
Expand All @@ -49,6 +63,6 @@ public static function plain(array $props = []): string
*/
public static function file(array $props = []): string
{
return self::build($props)->file;
return self::create($props)->file;
}
}

0 comments on commit d9fbb34

Please sign in to comment.