-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 2342fc1
Showing
24 changed files
with
2,966 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
composer.phar | ||
vendor/ | ||
|
||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
composer.lock |
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 @@ | ||
Copyright (c) 2014 AntiMattr Common Product Model | ||
|
||
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. |
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,157 @@ | ||
common-product | ||
============== | ||
|
||
The AntiMattr common product is a library that provides a shared Product interface. | ||
|
||
Installation | ||
============ | ||
|
||
Add the following to your composer.json file: | ||
|
||
```json | ||
{ | ||
"require": { | ||
"antimattr/common-product": "~1.0@stable" | ||
} | ||
} | ||
``` | ||
|
||
Install the libraries by running: | ||
|
||
```bash | ||
composer install | ||
``` | ||
|
||
If everything worked, the Common Product can now be found at vendor/antimattr/common-product. | ||
|
||
Model | ||
===== | ||
|
||
```javascript | ||
/* | ||
* A configurable Product has Attributes (ex. size, color) | ||
* Those Attributes have Options (ex. red, blue, small, medium) | ||
* A configurable Product has Variations which are unique combinations of Options. | ||
*/ | ||
|
||
Product = { | ||
attributes: [ | ||
Attribute, // color | ||
Attribute, // size | ||
], | ||
createdAt: Date, | ||
currency: string, // USD | ||
description: string, | ||
dimensionUnit: string, // For Height, Length, Width | ||
height: int, // Smallest unit for measurement system | ||
id: string || int, | ||
images: [ | ||
Image, | ||
Image, | ||
Image, | ||
], | ||
length: int, // Smallest unit for measurement system | ||
mpn: string, | ||
msrp: int, // Smallest unit for currency | ||
price: int, // Smallest unit for currency | ||
publishedAt: Date, | ||
quantity: int, | ||
sku: string, | ||
status: string, | ||
title: string, | ||
upc: string, | ||
updatedAt: Date, | ||
variations: [ | ||
Variation, // color_red size_small (an object containing to Variants, one for color red and one for size medium) | ||
Variation, // color_red size_medium | ||
Variation, // color_red size_large | ||
Variation, // color_blue size_small | ||
Variation, // color_blue size_medium | ||
Variation // color_blue size_large | ||
], | ||
weight: int, // Smallest unit for measurement system | ||
weigthUnit: string, | ||
width: int, // Smallest unit for measurement system | ||
}; | ||
|
||
Attribute { | ||
id: 'id', | ||
name: 'Color', | ||
options: [ | ||
Option, // red | ||
Option, // orange | ||
Option, // yellow | ||
Option, // green | ||
Option, // blue | ||
Option, // indigo | ||
Option, // violet | ||
] | ||
}; | ||
|
||
Option { | ||
attribute: Attribute, // ReferenceOne | ||
value: 'Red', | ||
uniqueIdentifier: 'color_red', // Concatenate Attribute name and variant value. This ensures there can be only one "red". | ||
variation: Variation, | ||
}; | ||
|
||
Variation extends Product { | ||
image: Image, | ||
options: [ // A single permutation of options creating a unique mapping of options | ||
Option, // color_red | ||
Option, // size_medium | ||
], | ||
position: int, // Default sort order for Variations, | ||
product: Product, // Parent Product | ||
uniqueIdentifier: 'color_red_size_medium', // Concatenate Option::uniqueIdentifier | ||
}; | ||
``` | ||
|
||
Pull Requests | ||
============= | ||
|
||
Pull Requests - PSR Standards | ||
----------------------------- | ||
|
||
Please use the pre-commit hook to run the fix all code to PSR standards | ||
|
||
Install once with | ||
|
||
```bash | ||
./bin/install.sh | ||
Copying /antimattr-common-product/bin/pre-commit.sh -> /antimattr-common-product/bin/../.git/hooks/pre-commit | ||
``` | ||
|
||
Pull Requests | ||
============= | ||
|
||
Pull Requests - PSR Standards | ||
----------------------------- | ||
|
||
Please use the pre-commit hook to fix all code to PSR standards | ||
|
||
Install once with | ||
|
||
```bash | ||
./bin/install.sh | ||
Copying /antimattr-common-product/bin/pre-commit.sh -> /antimattr-common-product/bin/../.git/hooks/pre-commit | ||
``` | ||
|
||
Pull Requests - Testing | ||
----------------------- | ||
|
||
Please make sure tests pass | ||
|
||
```bash | ||
$ vendor/bin/phpunit tests | ||
``` | ||
|
||
Pull Requests - Code Sniffer and Fixer | ||
-------------------------------------- | ||
|
||
Don't have the pre-commit hook running, please make sure to run the fixer/sniffer manually | ||
|
||
```bash | ||
$ vendor/bin/php-cs-fixer fix src/ | ||
$ vendor/bin/php-cs-fixer fix tests/ | ||
``` |
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIRECTORY=`pwd` | ||
BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
PROJECT_DIRECTORY="$BIN_DIRECTORY/.." | ||
|
||
echo "Copying $BIN_DIRECTORY/pre-commit.sh -> $PROJECT_DIRECTORY/.git/hooks/pre-commit" | ||
|
||
cp "$BIN_DIRECTORY/pre-commit.sh" "$PROJECT_DIRECTORY/.git/hooks/pre-commit" | ||
chmod 0777 "$PROJECT_DIRECTORY/.git/hooks/pre-commit" | ||
cd $CURRENT_DIRECTORY; |
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,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "pre commit hook start" | ||
|
||
CURRENT_DIRECTORY=`pwd` | ||
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.." | ||
|
||
cd $PROJECT_DIRECTORY; | ||
PHP_CS_FIXER="vendor/bin/php-cs-fixer" | ||
|
||
HAS_PHP_CS_FIXER=false | ||
|
||
if [ -x "$PHP_CS_FIXER" ]; then | ||
HAS_PHP_CS_FIXER=true | ||
fi | ||
|
||
if $HAS_PHP_CS_FIXER; then | ||
git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do | ||
${PHP_CS_FIXER} fix --verbose ${line}; | ||
git add "$line"; | ||
done | ||
else | ||
echo "" | ||
echo "Please install php-cs-fixer, e.g.:" | ||
echo "" | ||
echo " composer require --dev fabpot/php-cs-fixer:dev-master" | ||
echo "" | ||
fi | ||
|
||
cd $CURRENT_DIRECTORY; | ||
echo "pre commit hook finish" |
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,35 @@ | ||
{ | ||
"name": "antimattr/common-product", | ||
"type": "library", | ||
"description": "Common Product Model", | ||
"keywords": ["antimattr", "product"], | ||
"homepage": "http://github.com/antimattr/common-product", | ||
"license": "MIT", | ||
"authors": [ | ||
{"name": "Matthew Fitzgerald", "email": "[email protected]"} | ||
], | ||
"require": { | ||
"php": ">=5.3.2", | ||
"doctrine/collections": "1.*" | ||
}, | ||
"require-dev": { | ||
"antimattr/test-case": "~1.0@stable", | ||
"phpunit/phpunit": "~4.0", | ||
"fabpot/php-cs-fixer": "dev-master" | ||
}, | ||
"minimum-stability": "dev", | ||
"autoload": { | ||
"psr-0": { | ||
"AntiMattr\\Common\\Product\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-0": { | ||
"AntiMattr\\TestCase\\": "vendor/antimattr/test-case/src", | ||
"AntiMattr\\Tests\\Common\\Product\\": "tests/" | ||
} | ||
}, | ||
"archive": { | ||
"exclude": ["bin", "tests", "*phpunit.xml"] | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Oops, something went wrong.