<commit_before>Zen Kommerce Core
=================
[![Test Coverage](http://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://codeclimate.com/github/inklabs/kommerce-core)
[![Build Status](https://travis-ci.org/inklabs/kommerce-core.svg?branch=master)](https://travis-ci.org/inklabs/kommerce-core)
[![Downloads](https://img.shields.io/packagist/dt/inklabs/kommerce-core.svg)](https://packagist.org/packages/inklabs/kommerce-core)
[![Apache License 2.0](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/inklabs/kommerce-core/blob/master/LICENSE.txt)

## Introduction

Zen Kommerce is a PHP shopping cart system written with SOLID design principles.
It is PSR compatible, dependency free, and contains 100% code coverage using TDD practices.

All code (including tests) conform to the PSR-2 coding standards. The namespace and autoloader
are using the PSR-4 standard.

## Description

This project is over 30,000 lines of code. Unit tests account for 30-40% of that total and execute in
under 10 seconds. The repository tests use an in-memory SQLite database.

## Architecture

![Flow of Control](https://i.imgur.com/IJ5Trm7.png)

* Action
    - These are the use cases into the application. Command Actions are passed a Command object containing the required
      data payload. There is nothing returned from the dispatch() method. Only exceptions are thrown if the
      Command/Transaction is invalid.
      
      ```php
      $productDTO->sku = 'NEW-SKU';
      $this->dispatch(new EditProductCommand($productDTO));
      ```
      
    - Query Actions are passed a Request and Response object. There is nothing returned from the dispatchQuery()
      method. The return value is attached to the Response as defined in the ResponseInterface
      (GetProductResponseInterface in this case). The main application can implement this or use/extend the
      provided one. 

      ```php
      $response = new GetProductResponse;
      $this->dispatchQuery(new GetProductRequest(1), $response);
      $productDTO = $response->getProductDTO();

      echo $productDTO->sku;
      echo $productDTO->price->unitPrice;
      echo $productDTO->tags[0]->name;
      ```

    - Attaching the return value to the Response is needed to maintain type hints. This allows for decoupling the main
      application from the Use Case handler implementation. The main application only needs to know about
      these objects from the above examples:<commit_msg>Clarifying Actions.<commit_after>Zen Kommerce Core
=================
[![Test Coverage](http://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://codeclimate.com/github/inklabs/kommerce-core)
[![Build Status](https://travis-ci.org/inklabs/kommerce-core.svg?branch=master)](https://travis-ci.org/inklabs/kommerce-core)
[![Downloads](https://img.shields.io/packagist/dt/inklabs/kommerce-core.svg)](https://packagist.org/packages/inklabs/kommerce-core)
[![Apache License 2.0](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/inklabs/kommerce-core/blob/master/LICENSE.txt)

## Introduction

Zen Kommerce is a PHP shopping cart system written with SOLID design principles.
It is PSR compatible, dependency free, and contains 100% code coverage using TDD practices.

All code (including tests) conform to the PSR-2 coding standards. The namespace and autoloader
are using the PSR-4 standard.

## Description

This project is over 30,000 lines of code. Unit tests account for 30-40% of that total and execute in
under 10 seconds. The repository tests use an in-memory SQLite database.

## Architecture

![Flow of Control](https://i.imgur.com/IJ5Trm7.png)

* Action
    - These are the use cases into the application. Command Actions are passed a Command object containing the required
      data payload. There is nothing returned from the dispatch() method. Only exceptions are thrown if the
      Command/Transaction is invalid.
      
      ```php
      $productDTO->sku = 'NEW-SKU';
      $this->dispatch(new EditProductCommand($productDTO));
      ```
      
    - Query Actions are passed a Request and Response object. There is nothing returned from the dispatchQuery()
      method. The return value is attached to the Response as defined in the ResponseInterface
      (GetProductResponseInterface in this case). The main application can implement this or use/extend the
      provided one. 

      ```php
      $response = new GetProductResponse;
      $this->dispatchQuery(new GetProductRequest(1), $response);
      $productDTO = $response->getProductDTO();

      echo $productDTO->sku;
      echo $productDTO->price->unitPrice;
      echo $productDTO->tags[0]->name;
      ```

    - Attaching the return value to the Response is needed to maintain type hints in your IDE. Using the
      command/query bus allows for decoupling the main application from the Use Case handler implementation.
      The main application only needs to know about these objects from the above examples:
{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.012313803376365442, 'mean_word_length': 3.87984496124031, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1231727', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1379, 'n_words': 478}