<commit_before>OrientDb entity manager
=============================

Install
```code
composer require spartaksun/orientdb-entity
```
Example of services.yml:
```yml 
services:
    orient:
        class: PhpOrient\PhpOrient
        public: false
        properties:
            hostname:   'localhost'
            port:        2424
            username:   'root'
            password:   '<PASSWORD>'
    orient.em:
        class: spartaksun\OrientDb\EntityManager
        arguments: [@orient, "your_orient_db_name"]
        properties:
            classMap:
                "Country": YourBundle\Entity\Country
```

Define entities by extending spartaksun\OrientDb\Entity class. 
Use internal validators or define your own by extending abstract spartaksun\OrientDb\Validators\Validator:
```php
/**
 * Country entity
 * @property $first_name
 * @property $last_name
 */
class Country extends spartaksun\OrientDb\Entity
{
    /**
     * {@inheritdoc}
     */
    public function validators()
    {
        return [
            'name' => [
                [
                    spartaksun\OrientDb\Validators\StringValidator::class, 
                    ['min' => 3, 'max' => 32],
                ],
            ],
        ];
    }
}
```


Usage in Symfony2 controller:
```php
$this->get('orient.em');
```

```
// Init repository
$repository = $this->get('orient.em')
        ->getRepository( Country::class );
```    
    
```
// Get all countries
$countries = $repository->findAll();
foreach($countries as $country) {
     echo $country->name . "\n";
}
```
        
```
// Add new country
$country = new Country();
$country->name = 'Ukraine';
```
        
```
if($repository->persist($country)) {
    $rid = $country->getRid();
} else {
    var_dump($country->getErrors());
}
```   
     
```
// find one
$country = $repository->find('name=?', 'Ukraine')
```
    <commit_msg>Example of usage (fix)<commit_after>OrientDb entity manager
=============================

Install
```code
composer require spartaksun/orientdb-entity
```
Example of services.yml:
```yml 
services:
    orient:
        class: PhpOrient\PhpOrient
        public: false
        properties:
            hostname:   'localhost'
            port:        2424
            username:   'root'
            password:   '<PASSWORD>'
    orient.em:
        class: spartaksun\OrientDb\EntityManager
        arguments: [@orient, "your_orient_db_name"]
        properties:
            classMap:
                "Country": YourBundle\Entity\Country
```

Define entities by extending spartaksun\OrientDb\Entity class. 
Use internal validators or define your own by extending abstract spartaksun\OrientDb\Validators\Validator:
```php
/**
 * Country entity
 * @property $first_name
 * @property $last_name
 */
class Country extends spartaksun\OrientDb\Entity
{
    /**
     * {@inheritdoc}
     */
    public function validators()
    {
        return [
            'name' => [
                [
                    spartaksun\OrientDb\Validators\StringValidator::class, 
                    ['min' => 3, 'max' => 32],
                ],
            ],
        ];
    }
}
```


Usage in Symfony2 controller:
```php
$this->get('orient.em');
```

```php
// Init repository
$repository = $this->get('orient.em')
        ->getRepository( Country::class );
```    
    
```php
// Get all countries
$countries = $repository->findAll();
foreach($countries as $country) {
     echo $country->name . "\n";
}
```
        
```php
// Add new country
$country = new Country();
$country->name = 'Ukraine';
```
        
```php
if($repository->persist($country)) {
    $rid = $country->getRid();
} else {
    var_dump($country->getErrors());
}
```   
     
```php
// find one
$country = $repository->find('name=?', 'Ukraine')
```
    
{'fraction_non_alphanumeric': 0.16224814422057265, 'fraction_numerical': 0.0042417815482502655, 'mean_word_length': 2.280869565217391, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2156449', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1109, 'n_words': 242}