Add model to map the Parse response

This commit is contained in:
David Garcia 2017-12-08 09:32:05 +00:00 committed by David Garcia
parent 1fb0d0bbc5
commit 0039e26be2

View File

@ -0,0 +1,67 @@
<?php
/*
* Copyright (C) 2013 Mailgun
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace Mailgun\Model\EmailValidation;
/**
* @author David Garcia <me@davidgarcia.cat>
*/
final class Parse
{
/**
* @var array
*/
private $parsed;
/**
* @var array
*/
private $unparseable;
/**
* Parse constructor.
*
* @param array $parsed
* @param array $unparseable
*/
private function __construct(array $parsed, array $unparseable)
{
$this->parsed = $parsed;
$this->unparseable = $unparseable;
}
/**
* @param array $data
*
* @return Parse
*/
public static function create(array $data)
{
return new self(
((isset($data['parsed']) && is_array($data['parsed'])) ? $data['parsed'] : []),
((isset($data['unparseable']) && is_array($data['unparseable'])) ? $data['unparseable'] : [])
);
}
/**
* @return array
*/
public function getParsed()
{
return $this->parsed;
}
/**
* @return array
*/
public function getUnparseable()
{
return $this->unparseable;
}
}