Initial commit
This commit is contained in:
88
src/Model/Base/AddressInterface.php
Normal file
88
src/Model/Base/AddressInterface.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for objects with a postal address
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
interface AddressInterface
|
||||
{
|
||||
/**
|
||||
* Get address line 1
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress1(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get address line 2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress2(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the city
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCity(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get the postcode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostcode(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get the country code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCountry(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Get the full location string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string;
|
||||
}
|
||||
|
||||
81
src/Model/Base/BaseCollection.php
Normal file
81
src/Model/Base/BaseCollection.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
abstract class BaseCollection extends \ArrayObject
|
||||
{
|
||||
const SORT_ASC = 'asc';
|
||||
const SORT_DESC = 'desc';
|
||||
|
||||
/**
|
||||
* Set the sort direction
|
||||
* @var string
|
||||
*/
|
||||
protected $sortDirection = self::SORT_ASC;
|
||||
|
||||
/**
|
||||
* The last sort direction, used for reset
|
||||
* @var string
|
||||
*/
|
||||
protected $storedDirection = null;
|
||||
|
||||
|
||||
/**
|
||||
* Set the sort direction
|
||||
*
|
||||
* @param string $sortDirection
|
||||
* @param bool $temporary
|
||||
* @return \Magdev\Dossier\Model\BaseCollection
|
||||
*/
|
||||
public function setSortDirection(string $sortDirection, bool $temporary = false): BaseCollection
|
||||
{
|
||||
if (!$temporary) {
|
||||
$this->storedDirection = $this->sortDirection;
|
||||
}
|
||||
$this->sortDirection = $sortDirection;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset a temporary sort direction
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\BaseCollection
|
||||
*/
|
||||
public function resetSortDirection(): BaseCollection
|
||||
{
|
||||
if ($this->storedDirection) {
|
||||
$this->sortDirection = $this->storedDirection;
|
||||
$this->storedDirection = null;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
253
src/Model/Base/BaseModel.php
Normal file
253
src/Model/Base/BaseModel.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
use Mni\FrontYAML\Document;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Magdev\Dossier\Model\Traits\VarnameConverterTrait;
|
||||
|
||||
/**
|
||||
* Abstract model for Markdown files
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
abstract class BaseModel
|
||||
{
|
||||
use VarnameConverterTrait;
|
||||
|
||||
/**
|
||||
* FrontYAML Document
|
||||
* @var \Mni\FrontYAML\Document
|
||||
*/
|
||||
protected $document = null;
|
||||
|
||||
/**
|
||||
* Additional data
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $additionalData = null;
|
||||
|
||||
/**
|
||||
* Set some properties to ignore while analysing
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $ignoredProperties = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Mni\FrontYAML\Document $document
|
||||
*/
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->additionalData = new \ArrayObject();
|
||||
$this->ignoredProperties = new \ArrayObject(array(
|
||||
'ignoreProperties',
|
||||
'document'
|
||||
));
|
||||
$this->load();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the document object
|
||||
*
|
||||
* @return \Mni\FrontYAML\Document
|
||||
*/
|
||||
public function getDocument(): Document
|
||||
{
|
||||
return $this->document;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the parsed Markdown part of the file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->document->getContent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the YAML content of the file
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getYAML(): array
|
||||
{
|
||||
$yaml = $this->document->getYAML();
|
||||
if (is_null($yaml)) {
|
||||
return array();
|
||||
}
|
||||
return $yaml;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper to access the page content as description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->getContent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get additional data
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getAdditionalData(): \ArrayObject
|
||||
{
|
||||
return $this->additionalData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if model has additional data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAdditionalData(): bool
|
||||
{
|
||||
return $this->additionalData->count() > 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an array with all data values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an ignored property
|
||||
*
|
||||
* @param string $prop
|
||||
* @return BaseModel
|
||||
*/
|
||||
protected function addIgnoredProperty(string $prop): BaseModel
|
||||
{
|
||||
if (!in_array($prop, $this->ignoredProperties->getArrayCopy())) {
|
||||
$this->ignoredProperties->append($prop);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add multiple ignored prperties
|
||||
*
|
||||
* @param array $props
|
||||
* @return BaseModel
|
||||
*/
|
||||
protected function addIgnoredProperties(array $props): BaseModel
|
||||
{
|
||||
foreach ($props as $prop) {
|
||||
$this->addIgnoredProperty($prop);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add additional data
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return \Magdev\Dossier\Model\Base\BaseModel
|
||||
*/
|
||||
protected function addAdditionalData(string $key, $value): BaseModel
|
||||
{
|
||||
$this->additionalData->append(array('key' => $key, 'value' => $value));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a property
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return \Magdev\Dossier\Model\Base\BaseModel
|
||||
*/
|
||||
protected function setProperty(string $key, $value): BaseModel
|
||||
{
|
||||
$prop = $this->convertCase($key);
|
||||
if (property_exists($this, $prop)) {
|
||||
$this->{$prop} = $value;
|
||||
} else if ($this instanceof BaseModel) {
|
||||
$this->addAdditionalData($prop, $value);
|
||||
} else {
|
||||
throw new InvalidArgumentException('Unknow property: '.__CLASS__.'::'.$prop);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load YAML data into model properties
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\Base\BaseModel
|
||||
*/
|
||||
protected function load(): BaseModel
|
||||
{
|
||||
$yaml = $this->getYAML();
|
||||
return $this->loadArray($yaml);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laod data from array
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Magdev\Dossier\Model\Base\BaseModel
|
||||
*/
|
||||
protected function loadArray(array $data): BaseModel
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->setProperty($key, $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
71
src/Model/Base/ModelExportableInterface.php
Normal file
71
src/Model/Base/ModelExportableInterface.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
/**
|
||||
* Interface for exportable models
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
interface ModelExportableInterface extends ModelInterface
|
||||
{
|
||||
/**
|
||||
* Get the data as assoziative array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData(): array;
|
||||
|
||||
|
||||
/**
|
||||
* Get the text content as string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText(): string;
|
||||
|
||||
|
||||
/**
|
||||
* Check if the model has data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasData(): bool;
|
||||
|
||||
|
||||
/**
|
||||
* Check if the model has text content
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasText(): bool;
|
||||
}
|
||||
|
||||
37
src/Model/Base/ModelInterface.php
Normal file
37
src/Model/Base/ModelInterface.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
interface ModelInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
72
src/Model/Base/PhotoInterface.php
Normal file
72
src/Model/Base/PhotoInterface.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Base;
|
||||
|
||||
/**
|
||||
* Interface for modle with photo capabilities
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
interface PhotoInterface
|
||||
{
|
||||
/**
|
||||
* Get the photo
|
||||
*
|
||||
* @return \SplFileInfo
|
||||
*/
|
||||
public function getPhoto(): \SplFileInfo;
|
||||
|
||||
|
||||
/**
|
||||
* Check if the model has a photo
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPhoto(): bool;
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the photo
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPhotoSize(): int;
|
||||
|
||||
|
||||
/**
|
||||
* Set the photo
|
||||
*
|
||||
* @param string $path
|
||||
* @return \Magdev\Dossier\Model\Base\PhotoInterface
|
||||
*/
|
||||
public function setPhoto(string $path): PhotoInterface;
|
||||
}
|
||||
|
||||
240
src/Model/CurriculumVitae.php
Normal file
240
src/Model/CurriculumVitae.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
use Magdev\Dossier\Model\CurriculumVitae\Entry;
|
||||
use Magdev\Dossier\Service\FormatterService;
|
||||
use Magdev\Dossier\Model\Base\BaseCollection;
|
||||
|
||||
/**
|
||||
* Collection of CV-Entries
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class CurriculumVitae extends BaseCollection
|
||||
{
|
||||
/**
|
||||
* Formatter Service
|
||||
* @var \Magdev\Dossier\Service\FormatterService
|
||||
*/
|
||||
protected $formatter = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magdev\Dossier\Service\FormatterService $formatter
|
||||
*/
|
||||
public function __construct(FormatterService $formatter)
|
||||
{
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter entries by tag
|
||||
*
|
||||
* @param string $tag
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function filterByTag(string $tag): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->getTag() == $tag) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter entries by industry
|
||||
*
|
||||
* @param string $industry
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function filterByIndustry(string $industry): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->getIndustry() == $industry) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter entries by certificates
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function filterByCertificates(): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->hasCertificates()) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get entries with qualification
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function getQualifications(): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->getQualification()) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter entries used for resume
|
||||
*
|
||||
* @param bool $useInResume
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function filterByUseInResume(bool $useInResume = true): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->useInResume()) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter entries by toolbox contents
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function filterByToolbox(): CurriculumVitae
|
||||
{
|
||||
$result = new self($this->formatter);
|
||||
foreach ($this as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($entry->getToolbox()->count() > 0) {
|
||||
$result->append($entry);
|
||||
}
|
||||
}
|
||||
$result->setSortDirection($this->sortDirection)->sort();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the length of experience sorted by industry
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getExperienceYears(): \ArrayObject
|
||||
{
|
||||
$result = new \ArrayObject();
|
||||
$entries = $this->filterByTag('experience');
|
||||
foreach ($entries as $entry) {
|
||||
/* @var $entry \Magdev\Dossier\Model\CurriculumVitae\Entry */
|
||||
if ($industry = $entry->getIndustry()) {
|
||||
if (!array_key_exists($industry, $result)) {
|
||||
$result[$industry] = 0;
|
||||
}
|
||||
$result[$industry] += $entry->getExperienceLength();
|
||||
}
|
||||
}
|
||||
$result->uasort(function(int $a, int $b) {
|
||||
return $a > $b ? -1 : 1;
|
||||
});
|
||||
|
||||
$formatter = $this->formatter;
|
||||
array_walk($result, function(int &$seconds, string $key) use ($formatter) {
|
||||
$seconds = $formatter->formatExperience($seconds);
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort by start date
|
||||
*
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae
|
||||
*/
|
||||
public function sort(): CurriculumVitae
|
||||
{
|
||||
$this->uasort(array($this, 'sortByStartDate'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sort function to sort by start date
|
||||
*
|
||||
* @param \Magdev\Dossier\Model\CurriculumVitae\Entry $a
|
||||
* @param \Magdev\Dossier\Model\CurriculumVitae\Entry $b
|
||||
* @return int
|
||||
*/
|
||||
protected function sortByStartDate(Entry $a, Entry $b): int
|
||||
{
|
||||
$first = $a->getStartDate()->format('U');
|
||||
$second = $b->getStartDate()->format('U');
|
||||
|
||||
if ($first == $second) {
|
||||
return 0;
|
||||
}
|
||||
if ($this->sortDirection == self::SORT_DESC) {
|
||||
return $first > $second ? -1 : 1;
|
||||
}
|
||||
return $first < $second ? -1 : 1;
|
||||
}
|
||||
}
|
||||
357
src/Model/CurriculumVitae/Entry.php
Normal file
357
src/Model/CurriculumVitae/Entry.php
Normal file
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\CurriculumVitae;
|
||||
|
||||
use Magdev\Dossier\Model\AbstractModel;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Analyzer\Base\AnalyzableInterface;
|
||||
use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Model for CV entries
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
{
|
||||
use PhotoTrait;
|
||||
|
||||
/**
|
||||
* Start date
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $startDate = null;
|
||||
|
||||
/**
|
||||
* End date
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $endDate = null;
|
||||
|
||||
/**
|
||||
* Tag - either education, experience or other
|
||||
* @var string
|
||||
*/
|
||||
protected $tag = '';
|
||||
|
||||
/**
|
||||
* Employer information
|
||||
* @var string
|
||||
*/
|
||||
protected $company = '';
|
||||
|
||||
/**
|
||||
* Obtained Qualification, i.e. graduations
|
||||
* @var string
|
||||
*/
|
||||
protected $qualification = '';
|
||||
|
||||
/**
|
||||
* Name of the position or role
|
||||
* @var string
|
||||
*/
|
||||
protected $position = '';
|
||||
|
||||
/**
|
||||
* Obtained skills
|
||||
* @var array
|
||||
*/
|
||||
protected $skills = array();
|
||||
|
||||
/**
|
||||
* Achievements - for the sake of glory!
|
||||
* @var array
|
||||
*/
|
||||
protected $achievements = array();
|
||||
|
||||
/**
|
||||
* Industry title
|
||||
* @var string
|
||||
*/
|
||||
protected $industry = '';
|
||||
|
||||
/**
|
||||
* Use this entry in resume
|
||||
* @var bool
|
||||
*/
|
||||
protected $useInResume = false;
|
||||
|
||||
/**
|
||||
* Certificate models
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $certs = null;
|
||||
|
||||
/**
|
||||
* Notes
|
||||
* @var string
|
||||
*/
|
||||
protected $notes = '';
|
||||
|
||||
/**
|
||||
* Toolbox
|
||||
* @var array
|
||||
*/
|
||||
protected $toolbox = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constrctor
|
||||
*
|
||||
* @param \Mni\FrontYAML\Document $document
|
||||
*/
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
$this->certs = new \ArrayObject();
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the start date
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartDate(): \DateTime
|
||||
{
|
||||
if ($this->startDate) {
|
||||
$date = new \DateTime($this->startDate);
|
||||
$date->setTime(0, 0);
|
||||
return $date;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the end date
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getEndDate(): \DateTime
|
||||
{
|
||||
if ($this->endDate) {
|
||||
$date = new \DateTime($this->endDate);
|
||||
$date->setTime(23, 59, 59);
|
||||
return $date;
|
||||
}
|
||||
$date = new \DateTime();
|
||||
$date->setTime(23, 59, 59);
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the tag for this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag(): string
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the company name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany(): string
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the qualification obtained
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQualification(): string
|
||||
{
|
||||
return $this->qualification;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the position/job title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition(): string
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the achievements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAchievements(): array
|
||||
{
|
||||
return $this->achievements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the obtained skills
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSkills(): array
|
||||
{
|
||||
return $this->skills;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the industry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIndustry(): string
|
||||
{
|
||||
return $this->industry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get notes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNotes(): string
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if this entry should be included in the resume
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function useInResume(): bool
|
||||
{
|
||||
return $this->useInResume;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachted certificates
|
||||
*
|
||||
* @return \ArrayObject(\Magdev\Dossier\Model\CurriculumVitae\Entry\Certificate[])
|
||||
*/
|
||||
public function getCertificates(): \ArrayObject
|
||||
{
|
||||
return $this->certs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if entry has certificates
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCertificates(): bool
|
||||
{
|
||||
return $this->certs->count() > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the toolbox
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getToolbox(): \ArrayObject
|
||||
{
|
||||
return new \ArrayObject($this->toolbox);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the length of this entry in seconds
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExperienceLength(): int
|
||||
{
|
||||
return $this->getEndDate()->format('U') - $this->getStartDate()->format('U');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Analyzer\Base\AnalyzableInterface::getAnalyzerData()
|
||||
*/
|
||||
public function getAnalyzerData(): array
|
||||
{
|
||||
$props = get_object_vars($this);
|
||||
foreach ($this->ignoredProperties as $prop) {
|
||||
unset($props[$prop]);
|
||||
}
|
||||
$props['text'] = $this->getContent();
|
||||
return $props;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\BaseModel::loadArray()
|
||||
*/
|
||||
protected function loadArray(array $data): BaseModel
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key == 'certs') {
|
||||
foreach ($value as $cert) {
|
||||
$c = new Entry\Certificate(PROJECT_ROOT.'/certs/'.$cert['path'], $cert['type']);
|
||||
$this->certs->append($c);
|
||||
}
|
||||
} else if ($key == 'photo') {
|
||||
$this->setPhoto($value);
|
||||
} else {
|
||||
$prop = $this->convertCase($key);
|
||||
if (property_exists($this, $prop)) {
|
||||
$this->{$prop} = $value;
|
||||
} else {
|
||||
$this->addAdditionalData($prop, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
117
src/Model/CurriculumVitae/Entry/Certificate.php
Normal file
117
src/Model/CurriculumVitae/Entry/Certificate.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\CurriculumVitae\Entry;
|
||||
|
||||
/**
|
||||
* Certificate Model
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Certificate
|
||||
{
|
||||
/**
|
||||
* Store the file object
|
||||
*
|
||||
* @var \SplFileObject
|
||||
*/
|
||||
protected $file = null;
|
||||
|
||||
/**
|
||||
* Store the type of this certificate
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $type
|
||||
*/
|
||||
public function __construct(string $path, string $type = '')
|
||||
{
|
||||
$this->file = new \SplFileObject($path);
|
||||
$this->setType($type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file object
|
||||
*
|
||||
* @return \SplFileObject
|
||||
*/
|
||||
public function getFileObject(): \SplFileObject
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the type og the certificate
|
||||
*
|
||||
* @param string $type
|
||||
* @return \Magdev\Dossier\Model\CurriculumVitae\Entry\Certificate
|
||||
*/
|
||||
public function setType(string $type): Certificate
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the type of the certificate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file contents as Data-URI
|
||||
*
|
||||
* @TODO Refactor to use UriHelperService
|
||||
* @deprecated Use UriHelperService instead
|
||||
* @return string
|
||||
*/
|
||||
public function getDataUri(): string
|
||||
{
|
||||
$fi = new \finfo();
|
||||
$mimetype = $fi->file($this->file->getRealPath(), FILEINFO_MIME);
|
||||
|
||||
return 'data:'.$mimetype.'; base64,'.base64_encode(file_get_contents($this->file->getRealPath()));
|
||||
}
|
||||
}
|
||||
154
src/Model/Intro.php
Normal file
154
src/Model/Intro.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Base\ModelExportableInterface;
|
||||
use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
use Magdev\Dossier\Analyzer\Base\AnalyzableInterface;
|
||||
|
||||
/**
|
||||
* Model for introduction page
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Intro extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
{
|
||||
const SHOW_TOP = 'top';
|
||||
const SHOW_BOTTOM = 'bottom';
|
||||
|
||||
use PhotoTrait;
|
||||
|
||||
/**
|
||||
* Quotes
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $quotes = null;
|
||||
|
||||
/**
|
||||
* Headline for intro page
|
||||
* @var string
|
||||
*/
|
||||
protected $headline = '';
|
||||
|
||||
/**
|
||||
* Place to show the quotes
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $showQuotes = self::SHOW_TOP;
|
||||
|
||||
|
||||
/**
|
||||
* Get the headline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadline(): string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Document $document
|
||||
*/
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
$this->quotes = new \ArrayObject();
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the quotes
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getQuotes(): \ArrayObject
|
||||
{
|
||||
return $this->quotes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the place where to show the quotes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShowQuotes(): string
|
||||
{
|
||||
return $this->showQuotes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\BaseModel::loadArray()
|
||||
*/
|
||||
protected function loadArray(array $data): BaseModel
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key == 'quotes') {
|
||||
foreach ($value as $quote) {
|
||||
$q = new Intro\Quote($quote);
|
||||
$this->quotes->append($q);
|
||||
}
|
||||
} else if ($key == 'photo') {
|
||||
$this->setPhoto($value);
|
||||
} else {
|
||||
$this->setProperty($key, $value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Analyzer\Base\AnalyzableInterface::getAnalyzerData()
|
||||
*/
|
||||
public function getAnalyzerData(): array
|
||||
{
|
||||
$props = get_object_vars($this);
|
||||
foreach ($this->ignoredProperties as $prop) {
|
||||
unset($props[$prop]);
|
||||
}
|
||||
$props['text'] = $this->getContent();
|
||||
return $props;
|
||||
}
|
||||
|
||||
}
|
||||
91
src/Model/Intro/Quote.php
Normal file
91
src/Model/Intro/Quote.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Intro;
|
||||
|
||||
|
||||
use Magdev\Dossier\Model\AbstractModel;
|
||||
|
||||
/**
|
||||
* Quote Model
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class Quote
|
||||
{
|
||||
/**
|
||||
* Quote text
|
||||
* @var string
|
||||
*/
|
||||
protected $quoteText = '';
|
||||
|
||||
/**
|
||||
* Author of the quote
|
||||
* @var string
|
||||
*/
|
||||
protected $quoteAuthor = '';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $quote
|
||||
*/
|
||||
public function __construct(array $quote)
|
||||
{
|
||||
$this->quoteText = $quote['text'];
|
||||
if (isset($quote['author'])) {
|
||||
$this->quoteAuthor = $quote['author'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the quote text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuoteText(): string
|
||||
{
|
||||
return $this->quoteText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the author of the quote
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuoteAuthor(): string
|
||||
{
|
||||
return $this->quoteAuthor;
|
||||
}
|
||||
|
||||
}
|
||||
422
src/Model/Person.php
Normal file
422
src/Model/Person.php
Normal file
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Person\Contact;
|
||||
use Magdev\Dossier\Analyzer\Base\AnalyzableInterface;
|
||||
use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
use Magdev\Dossier\Model\Person\Reference;
|
||||
|
||||
/**
|
||||
* Model for the person object
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class Person extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
{
|
||||
use PhotoTrait;
|
||||
|
||||
/**
|
||||
* First name
|
||||
* @var string
|
||||
*/
|
||||
protected $firstname = '';
|
||||
|
||||
/**
|
||||
* Last name
|
||||
* @var string
|
||||
*/
|
||||
protected $lastname = '';
|
||||
|
||||
/**
|
||||
* Birthdate
|
||||
* @var string
|
||||
*/
|
||||
protected $birthdate = '';
|
||||
|
||||
/**
|
||||
* Birthplace
|
||||
* @var string
|
||||
*/
|
||||
protected $birthplace = '';
|
||||
|
||||
/**
|
||||
* Tagline
|
||||
* @var string
|
||||
*/
|
||||
protected $tagline = '';
|
||||
|
||||
/**
|
||||
* Current residence
|
||||
* @var string
|
||||
*/
|
||||
protected $residence = '';
|
||||
|
||||
/**
|
||||
* Status
|
||||
* @var string
|
||||
*/
|
||||
protected $status = '';
|
||||
|
||||
/**
|
||||
* Nationality
|
||||
* @var string
|
||||
*/
|
||||
protected $nationality = '';
|
||||
|
||||
/**
|
||||
* Work license
|
||||
* @var string
|
||||
*/
|
||||
protected $workLicense = '';
|
||||
|
||||
/**
|
||||
* Languages
|
||||
* @var array
|
||||
*/
|
||||
protected $languages = array();
|
||||
|
||||
/**
|
||||
* Personal Links
|
||||
* @var array
|
||||
*/
|
||||
protected $links = array();
|
||||
|
||||
/**
|
||||
* Contact
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $contacts = null;
|
||||
|
||||
/**
|
||||
* References
|
||||
* @var \ArrayObject
|
||||
*/
|
||||
protected $references = null;
|
||||
|
||||
/**
|
||||
* Personal Interests
|
||||
* @var array
|
||||
*/
|
||||
protected $interests = array();
|
||||
|
||||
/**
|
||||
* Current Projects
|
||||
* @var array
|
||||
*/
|
||||
protected $projects = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Mni\FrontYAML\Document $document
|
||||
*/
|
||||
public function __construct(Document $document)
|
||||
{
|
||||
$this->contacts = new \ArrayObject();
|
||||
$this->references = new \ArrayObject();
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstname(): string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the last name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastname(): string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the full name
|
||||
*
|
||||
* @param bool $reversed
|
||||
* @return string
|
||||
*/
|
||||
public function getName(bool $reversed = false): string
|
||||
{
|
||||
if ($reversed) {
|
||||
return $this->lastname.', '.$this->firstname;
|
||||
}
|
||||
return $this->firstname.' '.$this->lastname;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the persons tagline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTagline(): string
|
||||
{
|
||||
return $this->tagline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the persons current residence
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResidence(): string
|
||||
{
|
||||
return $this->residence;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the birthday date
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getBirthdate(): \DateTime
|
||||
{
|
||||
if ($this->birthdate) {
|
||||
return new \DateTime($this->birthdate);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the birthplace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBirthplace(): string
|
||||
{
|
||||
return $this->birthplace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the family status
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the nationality
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNationality(): string
|
||||
{
|
||||
return $this->nationality;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get languages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLanguages(): array
|
||||
{
|
||||
return $this->languages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get personal links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks(): array
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get contact info
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getContacts(): \ArrayObject
|
||||
{
|
||||
return $this->contacts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get references
|
||||
*
|
||||
* @return \ArrayObject
|
||||
*/
|
||||
public function getReferences(): \ArrayObject
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get personal interests
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInterests(): array
|
||||
{
|
||||
return $this->interests;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current projects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProjects(): array
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the work license
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWorkLicense(): string
|
||||
{
|
||||
return $this->workLicense;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the email address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->getContactType('email')->getAddress();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the phone number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone(): string
|
||||
{
|
||||
return $this->getContactType('phone')->getAddress();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a contact with a specific type
|
||||
*
|
||||
* @param string $type
|
||||
* @return \Magdev\Dossier\ModelContact
|
||||
*/
|
||||
public function getContactType(string $type): Contact
|
||||
{
|
||||
foreach ($this->getContacts() as $contact) {
|
||||
/* @var $contact \Magdev\Dossier\Model\Person\Contact */
|
||||
|
||||
if ($contact->getType() == $type) {
|
||||
return $contact->getAddress();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\BaseModel::loadArray()
|
||||
*/
|
||||
protected function loadArray(array $data): BaseModel
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key == 'photo') {
|
||||
$this->setPhoto($value);
|
||||
} else if ($key == 'contact') {
|
||||
foreach ($value as $type => $address) {
|
||||
if ($type == 'accounts' && is_array($address)) {
|
||||
foreach ($address as $a) {
|
||||
$this->contacts->append(new Contact($a['address'], $a['type']));
|
||||
}
|
||||
} else {
|
||||
$this->contacts->append(new Contact($address, $type));
|
||||
}
|
||||
}
|
||||
} else if ($key == 'references') {
|
||||
foreach ($value as $reference) {
|
||||
$this->references->append(new Reference($reference));
|
||||
}
|
||||
} else {
|
||||
$this->setProperty($key, $value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Analyzer\Base\AnalyzableInterface::getAnalyzerData()
|
||||
*/
|
||||
public function getAnalyzerData(): array
|
||||
{
|
||||
$props = get_object_vars($this);
|
||||
foreach ($this->ignoredProperties as $prop) {
|
||||
unset($props[$prop]);
|
||||
}
|
||||
$props['text'] = $this->getContent();
|
||||
return $props;
|
||||
}
|
||||
}
|
||||
85
src/Model/Person/Contact.php
Normal file
85
src/Model/Person/Contact.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
/**
|
||||
* Contact model
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Contact
|
||||
{
|
||||
/**
|
||||
* Contact address
|
||||
* @var string
|
||||
*/
|
||||
protected $address = '';
|
||||
|
||||
/**
|
||||
* Contact type
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $address
|
||||
* @param string $type
|
||||
*/
|
||||
public function __construct(string $address, string $type)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the contact type
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the contact address
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress(): string
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
}
|
||||
|
||||
192
src/Model/Person/Reference.php
Normal file
192
src/Model/Person/Reference.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
|
||||
/**
|
||||
* Model for job references
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Reference extends BaseModel
|
||||
{
|
||||
/**
|
||||
* Reference description
|
||||
* @var string
|
||||
*/
|
||||
protected $decription = '';
|
||||
|
||||
/**
|
||||
* Name of a possible contact person
|
||||
* @var string
|
||||
*/
|
||||
protected $contactName = '';
|
||||
|
||||
/**
|
||||
* Email address of a possible contact person
|
||||
* @var string
|
||||
*/
|
||||
protected $contactEmail = '';
|
||||
|
||||
/**
|
||||
* Phone number of a possible contact person
|
||||
* @var string
|
||||
*/
|
||||
protected $contactPhone = '';
|
||||
|
||||
|
||||
/**
|
||||
* Refrence is published and can be viewed online
|
||||
* @var bool
|
||||
*/
|
||||
protected $public = false;
|
||||
|
||||
/**
|
||||
* Link to a published reference
|
||||
* @var string
|
||||
*/
|
||||
protected $publicLink = '';
|
||||
|
||||
|
||||
/**
|
||||
* Example work as file
|
||||
* @var \SplFileObject
|
||||
*/
|
||||
protected $file = null;
|
||||
|
||||
/**
|
||||
* Link to an example work
|
||||
* @var string
|
||||
*/
|
||||
protected $fileLink = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->loadArray($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the description of the reference
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDecription(): string
|
||||
{
|
||||
return $this->decription;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of a possible contact person
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContactName(): string
|
||||
{
|
||||
return $this->contactName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the email address of a possible contact person
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContactEmail(): string
|
||||
{
|
||||
return $this->contactEmail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the phone number of a possible contact person
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContactPhone(): string
|
||||
{
|
||||
return $this->contactPhone;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the reference is published and can be viewed online
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPublic(): bool
|
||||
{
|
||||
return $this->public;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lik to a published example work
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function getPublicLink(): string
|
||||
{
|
||||
return $this->publicLink;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Example work file
|
||||
*
|
||||
* @return \SplFileObject
|
||||
*/
|
||||
public function getFile(): \SplFileObject
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the link to a file with example work
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileLink(): string
|
||||
{
|
||||
return $this->fileLink;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
91
src/Model/Project.php
Normal file
91
src/Model/Project.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
|
||||
class Project extends BaseModel
|
||||
{
|
||||
protected $name = '';
|
||||
protected $status = '';
|
||||
protected $url = '';
|
||||
protected $shortDescription = '';
|
||||
protected $stack = '';
|
||||
protected $role = '';
|
||||
|
||||
|
||||
|
||||
public function getRole(): string
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStack(): string
|
||||
{
|
||||
return $this->stack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getShortDescription(): string
|
||||
{
|
||||
return $this->shortDescription;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
149
src/Model/Traits/AddressTrait.php
Normal file
149
src/Model/Traits/AddressTrait.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Traits;
|
||||
|
||||
trait AddressTrait
|
||||
{
|
||||
/**
|
||||
* Address line 1
|
||||
* @var string
|
||||
*/
|
||||
protected $address1 = '';
|
||||
|
||||
/**
|
||||
* Address line 2
|
||||
* @var string
|
||||
*/
|
||||
protected $address2 = '';
|
||||
|
||||
/**
|
||||
* Name of the city
|
||||
* @var string
|
||||
*/
|
||||
protected $city = '';
|
||||
|
||||
/**
|
||||
* Postcode
|
||||
* @var string
|
||||
*/
|
||||
protected $postcode = '';
|
||||
|
||||
/**
|
||||
* Conutry code
|
||||
* @var string
|
||||
*/
|
||||
protected $country = '';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getAddress1()
|
||||
*/
|
||||
public function getAddress1(): string
|
||||
{
|
||||
return $this->address1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getAddress2()
|
||||
*/
|
||||
public function getAddress2(): string
|
||||
{
|
||||
return $this->address2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getCity()
|
||||
*/
|
||||
public function getCity(): string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getPostcode()
|
||||
*/
|
||||
public function getPostcode(): string
|
||||
{
|
||||
return $this->postcode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getCountry()
|
||||
*/
|
||||
public function getCountry(): string
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\AddressInterface::getLocation()
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
$location = '';
|
||||
if ($this->postcode) {
|
||||
$location .= $this->postcode.' ';
|
||||
}
|
||||
if ($this->city) {
|
||||
$location .= $this->city;
|
||||
}
|
||||
if ($this->country) {
|
||||
$location .= ' ('.$this->country.')';
|
||||
}
|
||||
return $location;
|
||||
}
|
||||
}
|
||||
78
src/Model/Traits/MarkdownExportTrait.php
Normal file
78
src/Model/Traits/MarkdownExportTrait.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Traits;
|
||||
|
||||
trait MarkdownExportTrait
|
||||
{
|
||||
protected $text = '';
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\ModelExportableInterface::getData()
|
||||
*/
|
||||
public function getData(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\ModelExportableInterface::getText()
|
||||
*/
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\ModelExportableInterface::hasData()
|
||||
*/
|
||||
public function hasData(): bool
|
||||
{
|
||||
return sizeof($this->getData()) > 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Model\Base\ModelExportableInterface::hasText()
|
||||
*/
|
||||
public function hasText(): bool
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
129
src/Model/Traits/PhotoTrait.php
Normal file
129
src/Model/Traits/PhotoTrait.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Traits;
|
||||
|
||||
use Magdev\Dossier\Model\AbstractModel;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
|
||||
/**
|
||||
* Trait to add a photo to a model
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
trait PhotoTrait
|
||||
{
|
||||
/**
|
||||
* Photo object
|
||||
* @var \SplFileInfo
|
||||
*/
|
||||
protected $photo = null;
|
||||
|
||||
/**
|
||||
* Size of the Photo
|
||||
* @var int
|
||||
*/
|
||||
protected $photoSize = -1;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the photo
|
||||
*
|
||||
* @return \SplFileInfo
|
||||
*/
|
||||
public function getPhoto(): \SplFileInfo
|
||||
{
|
||||
return $this->photo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the model has a photo
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPhoto(): bool
|
||||
{
|
||||
return $this->photo instanceof \SplFileInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file contents as Data-URI
|
||||
*
|
||||
* @TODO Refactor to use UriHelperService
|
||||
* @deprecated Use UriHelperService instead
|
||||
* @return string
|
||||
*/
|
||||
public function getPhotoDataUri(): string
|
||||
{
|
||||
if ($this->hasPhoto()) {
|
||||
$fi = new \finfo();
|
||||
$mimetype = $fi->file($this->photo->getRealPath(), FILEINFO_MIME);
|
||||
|
||||
return 'data:'.$mimetype.'; base64,'.base64_encode(file_get_contents($this->photo->getRealPath()));
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the photo
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPhotoSize(): int
|
||||
{
|
||||
if ($this->photoSize == -1) {
|
||||
if ($this->hasPhoto()) {
|
||||
if ($size = getimagesize($this->photo->getRealPath())) {
|
||||
$this->photoSize = $size[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->photoSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the photo
|
||||
*
|
||||
* @param string $path
|
||||
* @return \Magdev\Dossier\Model\Base\PhotoInterface
|
||||
*/
|
||||
public function setPhoto(string $path): PhotoInterface
|
||||
{
|
||||
$this->photo = new \SplFileInfo(PROJECT_ROOT.'/'.$path);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
48
src/Model/Traits/VarnameConverterTrait.php
Normal file
48
src/Model/Traits/VarnameConverterTrait.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Model\Traits;
|
||||
|
||||
trait VarnameConverterTrait
|
||||
{
|
||||
/**
|
||||
* Convert snake_case to camelCase
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
protected function convertCase(string $string): string
|
||||
{
|
||||
$res = str_replace('_', '', ucwords($string, '_'));
|
||||
$res[0] = strtolower($res[0]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user