Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge pr to be uptodate #1

Merged
merged 4 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Formatter/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function addVCard(VCard $vCard): self

public function download(): void
{
foreach ($this->getHeaders() as $header) {
header($header);
foreach ($this->getHeaders() as $key => $value) {
header(sprintf("%s: %s", $key, $value));
}

echo $this->getContent();
Expand Down
10 changes: 10 additions & 0 deletions src/Formatter/Property/RoleFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace JeroenDesloovere\VCard\Formatter\Property;

final class RoleFormatter extends SimpleNodeFormatter
{

}
16 changes: 16 additions & 0 deletions src/Parser/Property/RoleParser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace JeroenDesloovere\VCard\Parser\Property;

use JeroenDesloovere\VCard\Property\Role;
use JeroenDesloovere\VCard\Property\NodeInterface;

final class RoleParser implements NodeParserInterface
{
public function parseLine(string $value, array $parameters = []): NodeInterface
{
return new Role($value);
}
}
34 changes: 34 additions & 0 deletions src/Property/Role.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace JeroenDesloovere\VCard\Property;

use JeroenDesloovere\VCard\Formatter\Property\RoleFormatter;
use JeroenDesloovere\VCard\Formatter\Property\NodeFormatterInterface;
use JeroenDesloovere\VCard\Parser\Property\RoleParser;
use JeroenDesloovere\VCard\Parser\Property\NodeParserInterface;
use JeroenDesloovere\VCard\Property\Value\StringValue;

final class Role extends StringValue implements PropertyInterface, SimpleNodeInterface
{
public function getFormatter(): NodeFormatterInterface
{
return new RoleFormatter($this);
}

public static function getNode(): string
{
return 'ROLE';
}

public static function getParser(): NodeParserInterface
{
return new RoleParser();
}

public function isAllowedMultipleTimes(): bool
{
return false;
}
}
2 changes: 2 additions & 0 deletions src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use JeroenDesloovere\VCard\Property\PropertyInterface;
use JeroenDesloovere\VCard\Property\Telephone;
use JeroenDesloovere\VCard\Property\Title;
use JeroenDesloovere\VCard\Property\Role;

final class VCard
{
Expand All @@ -42,6 +43,7 @@ final class VCard
Gender::class,
Nickname::class,
Title::class,
Role::class,
Birthdate::class,
Anniversary::class,
Email::class,
Expand Down
5 changes: 4 additions & 1 deletion tests/VCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use JeroenDesloovere\VCard\Property\Photo;
use JeroenDesloovere\VCard\Property\Telephone;
use JeroenDesloovere\VCard\Property\Title;
use JeroenDesloovere\VCard\Property\Role;
use JeroenDesloovere\VCard\VCard;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
Expand Down Expand Up @@ -80,6 +81,7 @@ private function setUpThirdVCard(): void
{
$this->thirdVCard = (new VCard(Kind::organization()))
->add(new Title('Apple'))
->add(new Role('Fruit'))
->add(new Photo(__DIR__ . '/assets/landscape.jpeg'))
->add(new Logo(__DIR__ . '/assets/landscape.jpeg'))
->add(new Telephone('+32 486 00 00 00'));
Expand Down Expand Up @@ -186,8 +188,9 @@ public function testVCardGetProperties(): void
$this->assertCount(1, $this->secondVCard->getProperties(Name::class));
$this->assertCount(1, $this->secondVCard->getProperties(Address::class));

$this->assertCount(4, $this->thirdVCard->getProperties());
$this->assertCount(5, $this->thirdVCard->getProperties());
$this->assertCount(1, $this->thirdVCard->getProperties(Title::class));
$this->assertCount(1, $this->thirdVCard->getProperties(Role::class));
$this->assertCount(1, $this->thirdVCard->getProperties(Photo::class));
$this->assertCount(1, $this->thirdVCard->getProperties(Logo::class));
$this->assertCount(1, $this->thirdVCard->getProperties(Telephone::class));
Expand Down