Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Class representing the API constraints on mail clasess.
This is a weird bit of data-in-code, but since we're open sourcing this lib, I think it is the right way to go. Also: Git gui doesn't know about untracked files. So that is why this is in its own commit.
- Loading branch information
Robert L. Carpenter
committed
Mar 28, 2013
1 parent
c05554c
commit cc9e14b
Showing
1 changed file
with
43 additions
and
0 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
<?php | |||
namespace SparkLib\Shipping\Endicia; | |||
|
|||
class MailClass { | |||
public $name; | |||
public $international; | |||
public $integrated_form; | |||
public $max_items; | |||
|
|||
public function __construct($name, $international = false, $integrated_form = null, $max_items = null){ | |||
$this->name = $name; | |||
$this->international = $international; | |||
$this->integrated_form = $integrated_form; | |||
$this->max_items = $max_items; | |||
} | |||
|
|||
public static function Express() { return new static('Express'); } | |||
public static function First() { return new static('First'); } | |||
public static function LibraryMail() { return new static('LibraryMail'); } | |||
public static function MediaMail() { return new static('MediaMail'); } | |||
public static function StandardPost() { return new static('StandardPost'); } | |||
public static function ParcelSelect() { return new static('ParcelSelect'); } | |||
public static function Priority() { return new static('Priority'); } | |||
public static function CriticalMail() { return new static('CriticalMail'); } | |||
|
|||
public static function FirstClassMailInternational() { return new static('FirstClassMailInternational', true, 'Form2976', 5); } | |||
public static function FirstClassPackageInternationalService() { return new static('FirstClassPackageInternationalService', true, 'Form2976', 5); } | |||
public static function PriorityMailInternational() { return new static('PriorityMailInternational', true, 'Form2976A'); } | |||
public static function ExpressMailInternational() { return new static('ExpressMailInternational', true, 'Form2976A'); } | |||
|
|||
public static function fromString($str) { | |||
if ( method_exists(get_class(), $str) ){ | |||
return static::$str(); | |||
} else { | |||
return null; | |||
} | |||
} | |||
|
|||
public function isInternational(){ | |||
return isset($this->international) && $this->international; | |||
} | |||
} | |||
|