-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
728 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: normalize composer.json | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'composer.json' | ||
|
||
jobs: | ||
normalize: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Validate Composer configuration | ||
run: composer validate --strict | ||
|
||
- name: Normalize composer.json | ||
run: | | ||
composer global require ergebnis/composer-normalize | ||
composer normalize --indent-style=space --indent-size=4 --no-check-lock --no-update-lock --no-interaction --ansi | ||
- uses: stefanzweifel/[email protected] | ||
with: | ||
commit_message: normalize composer.json |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: normalize markdown | ||
|
||
on: | ||
push: | ||
paths: | ||
- '*.md' | ||
|
||
jobs: | ||
normalize: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prettify markdown | ||
uses: creyD/[email protected] | ||
with: | ||
prettier_options: --write **/*.md |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: run-tests | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
test: | ||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: [8.0] | ||
laravel: [8.*] | ||
dependency-version: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 8.* | ||
testbench: 6.* | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
keys: | | ||
dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer- | ||
dependencies-laravel-${{ matrix.laravel }}-php- | ||
dependencies-laravel- | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update | ||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest | ||
- name: Execute tests | ||
run: vendor/bin/phpunit |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: "Close stale issues" | ||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
default: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days' | ||
stale-issue-label: 'stale' | ||
exempt-issue-labels: 'bug,enhancement,documentation,help wanted,next release,next major release' | ||
days-before-stale: 21 | ||
days-before-close: 7 | ||
|
||
invalid: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'This issue is stale because it has been labeled as invalid.' | ||
stale-issue-label: 'stale' | ||
only-labels: 'invalid' | ||
days-before-stale: 1 | ||
days-before-close: 2 | ||
|
||
duplicate: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'This issue is stale because it has been labeled as duplicate.' | ||
stale-issue-label: 'stale' | ||
only-labels: 'duplicate' | ||
days-before-stale: 1 | ||
days-before-close: 2 | ||
|
||
wontfix: | ||
timeout-minutes: 1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'This issue is stale because it has been labeled as wontfix.' | ||
stale-issue-label: 'stale' | ||
only-labels: 'wontfix' | ||
days-before-stale: 1 | ||
days-before-close: 2 |
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 |
---|---|---|
@@ -1 +1,34 @@ | ||
# Laravel vCard | ||
|
||
## Usage | ||
|
||
```php | ||
Vcard::make() | ||
->fullName('John Adam Smith') | ||
->name('Smith', 'John', 'Adam') | ||
->email('[email protected]') | ||
->email('[email protected]', [Email::WORK, Email::INTERNET]) | ||
->tel('+1234567890', [Tel::HOME, Tel::VOICE]) | ||
->tel('+0987654321', [Tel::WORK, Tel::VOICE]) | ||
->tel('+0123456789', [Tel::CELL, Tel::VOICE]) | ||
->url('https://johnsmith.com') | ||
->url('https://company.com') | ||
->bday(Carbon::parse('1990-06-24')); | ||
``` | ||
|
||
```vcard | ||
BEGIN:VCARD | ||
VERSION:4.0 | ||
FN;CHARSET=UTF-8:John Adam Smith | ||
N;CHARSET=UTF-8:Smith;John;Adam;; | ||
EMAIL;TYPE=INTERNET:[email protected] | ||
EMAIL;TYPE=WORK;TYPE=INTERNET:[email protected] | ||
TEL;TYPE=HOME;TYPE=VOICE:+1234567890 | ||
TEL;TYPE=WORK;TYPE=VOICE:+0987654321 | ||
TEL;TYPE=CELL;TYPE=VOICE:+0123456789 | ||
URL:https://johnsmith.com | ||
URL:https://company.com | ||
BDAY:1990-06-24 | ||
REV:2021-02-25T10:30:45.000000Z | ||
END:VCARD | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src/</directory> | ||
</include> | ||
</coverage> | ||
<php> | ||
<env name="APP_ENV" value="testing" force="true"/> | ||
</php> | ||
</phpunit> |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
use DateTimeInterface; | ||
|
||
class Bday extends Property | ||
{ | ||
protected DateTimeInterface $bday; | ||
|
||
public function __construct(DateTimeInterface $bday) | ||
{ | ||
$this->bday = $bday; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return "BDAY:{$this->bday->format('Y-m-d')}"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
class Email extends Property | ||
{ | ||
public const INTERNET = 'INTERNET'; | ||
public const WORK = 'WORK'; | ||
|
||
protected string $email; | ||
|
||
/** @var string[] */ | ||
protected array $types; | ||
|
||
public function __construct(string $email, array $types) | ||
{ | ||
$this->email = $email; | ||
$this->types = $types; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
$types = implode(';', array_map( | ||
fn(string $type): string => "TYPE={$type}", | ||
$this->types | ||
)); | ||
|
||
return "EMAIL;{$types}:{$this->email}"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
class Gender extends Property | ||
{ | ||
public const FEMALE = 'F'; | ||
public const MALE = 'M'; | ||
|
||
protected string $gender; | ||
|
||
public function __construct(string $gender) | ||
{ | ||
$this->gender = $gender; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return "GENDER:{$this->gender}"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
class Kind extends Property | ||
{ | ||
public const INDIVIDUAL = 'individual'; | ||
public const ORGANIZATION = 'organization'; | ||
public const GROUP = 'group'; | ||
|
||
protected string $kind; | ||
|
||
public function __construct(string $kind) | ||
{ | ||
$this->kind = $kind; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return "KIND:{$this->kind}"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
use Illuminate\Support\Str; | ||
use InvalidArgumentException; | ||
|
||
class Photo extends Property | ||
{ | ||
protected string $photo; | ||
|
||
public function __construct(string $photo) | ||
{ | ||
if(!Str::startsWith($photo, 'data:image/jpeg;base64,')) { | ||
throw new InvalidArgumentException('Photo property has to be a jpeg base64 data-uri.'); | ||
} | ||
|
||
$this->photo = $photo; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return "PHOTO:{$this->photo}"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Astrotomic\Vcard\Properties; | ||
|
||
abstract class Property | ||
{ | ||
abstract public function __toString(): string; | ||
} |
Oops, something went wrong.