Skip to content

Commit

Permalink
nickname method camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreLebedel committed Oct 31, 2024
1 parent aeadd4d commit 7df1400
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ $vCard->getX('main-hobby'); // :string|array
```

> [!NOTE]
> **"Pseudo-singular" properties**
> In the [RFC 6350](https://datatracker.ietf.org/doc/html/rfc6350), most of properties can be present multiple times in a vCard. For example the `FN` (fullName) property can be present 1 or multiple times, and accompagnied by attributes to distinct them.
> In this package, we assume that some of properties (like fullName) got a unique main value. This *`getProperty()`* methods will return this main value, as well as the sub-object `$vCard->relevantData`.
> **"Pseudo-singular" properties:** [RFC 6350](https://datatracker.ietf.org/doc/html/rfc6350) allows most of properties to be present multiple times in a vCard. For example the `FN` (fullName) property can be present 1 or multiple times, and accompagnied by attributes to distinct them.
> In this package, we assume that some of properties (like fullName) got a **unique main value**. The vCard's *`getProperty()`* methods will return this main value, as well as the sub-object `$vCard->relevantData`.
> The complete set of value is stil available in the root of `$vCard` object.
### Build vCard
Expand Down
4 changes: 2 additions & 2 deletions src/Models/VCardV30.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class VCardV30 extends AbstractVCard

public $mailer = null;

public $sourceName = null;
public $sourceName = null; // alias of name

public $nickname = null;

public $prodid = null;

public $profile = null;

public $sortString = null;
public $sortString = null; // alias of sort-string

public $source = null;
}
14 changes: 7 additions & 7 deletions src/VCardBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,27 +363,27 @@ public function category(string $category): self
return $this;
}

public function nicknames(array $nicknames): self
public function nickNames(array $nickNames): self
{
$property = $this->getProperty('nickname');
if ($property) {
$property->makeField(implode(',', $nicknames));
$property->makeField(implode(',', $nickNames));
}

return $this;
}

public function nickname(string $nickname): self
public function nickName(string $nickName): self
{
$property = $this->getProperty('nickname');
if ($property) {
$field = (! empty($property->fields)) ? reset($property->fields) : $property->makeField('');
$nicknamesArray = $field->render()->value;
if (! in_array($nickname, $nicknamesArray)) {
$nicknamesArray[] = $nickname;
$nickNamesArray = $field->render()->value;
if (! in_array($nickName, $nickNamesArray)) {
$nickNamesArray[] = $nickName;
}
$property->fields = [];
$property->makeField(implode(',', $nicknamesArray));
$property->makeField(implode(',', $nickNamesArray));
}

return $this;
Expand Down

0 comments on commit 7df1400

Please sign in to comment.