Test Setup Failed
Push — testing ( b23bbe...f4ada3 )
by Roman
06:22 queued 03:28
created

Model   C

Complexity

Total Complexity 54

Size/Duplication

Total Lines 299
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 52.83%

Importance

Changes 0
Metric Value
wmc 54
lcom 1
cbo 7
dl 0
loc 299
ccs 56
cts 106
cp 0.5283
rs 6.4799
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A newEloquentBuilder() 0 4 1
A newBaseQueryBuilder() 0 6 1
A freshTimestamp() 0 4 1
A fromDateTime() 0 14 3
A asDateTime() 0 9 2
A originalIsNumericallyEquivalent() 0 15 4
A getQualifiedKeyName() 0 4 1
A qualifyColumn() 0 4 1
B setAttribute() 0 33 7
A __call() 0 9 2
A newCassandraCollection() 0 8 3
B originalIsEquivalent() 0 26 9
B isCassandraObject() 0 15 8
A isCompareableCassandraObject() 0 10 3
B valueFromCassandraObject() 0 30 8

How to fix   Complexity   

Complex Class

Complex classes like Model often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Model, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace lroman242\LaravelCassandra\Eloquent;
4
5
use Carbon\Carbon;
6
use Cassandra\Rows;
7
use Cassandra\Timestamp;
8
use lroman242\LaravelCassandra\Collection;
9
use lroman242\LaravelCassandra\Query\Builder as QueryBuilder;
10
use Illuminate\Database\Eloquent\Model as BaseModel;
11
use Illuminate\Support\Str;
12
13
abstract class Model extends BaseModel
14
{
15
    /**
16
     * The connection name for the model.
17
     *
18
     * @var string
19
     */
20
    protected $connection = 'cassandra';
21
22
    /**
23
     * Indicates if the IDs are auto-incrementing.
24
     * This is not possible in cassandra so we override this
25
     *
26 18
     * @var bool
27
     */
28 18
    public $incrementing = false;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function newEloquentBuilder($query)
34 18
    {
35
        return new Builder($query);
36 18
    }
37
38 18
    /**
39
     * @inheritdoc
40
     */
41
    protected function newBaseQueryBuilder()
42
    {
43
        $connection = $this->getConnection();
44 12
45
        return new QueryBuilder($connection, null, $connection->getPostProcessor());
0 ignored issues
show
Compatibility introduced by
$connection of type object<Illuminate\Database\Connection> is not a sub-type of object<lroman242\LaravelCassandra\Connection>. It seems like you assume a child class of the class Illuminate\Database\Connection to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Documentation introduced by
$connection->getPostProcessor() is of type object<Illuminate\Databa...y\Processors\Processor>, but the function expects a null|object<lroman242\La...sandra\Query\Processor>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46 12
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function freshTimestamp()
52 12
    {
53
        return new Timestamp();
0 ignored issues
show
Bug Best Practice introduced by
The return type of return new \Cassandra\Timestamp(); (Cassandra\Timestamp) is incompatible with the return type of the parent method Illuminate\Database\Eloquent\Model::freshTimestamp of type Illuminate\Support\Carbon.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
54
    }
55 12
56 12
    /**
57
     * @inheritdoc
58
     */
59
    public function fromDateTime($value)
60 1
    {
61 1
        // If the value is already a Timestamp instance, we don't need to parse it.
62
        if ($value instanceof Timestamp) {
0 ignored issues
show
Bug introduced by
The class Cassandra\Timestamp does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
63
            return $value;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $value; (Cassandra\Timestamp) is incompatible with the return type of the parent method Illuminate\Database\Eloquent\Model::fromDateTime of type integer|string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
64 1
        }
65
66
        // Let Eloquent convert the value to a DateTime instance.
67
        if (!$value instanceof \DateTime) {
68
            $value = parent::asDateTime($value);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (asDateTime() instead of fromDateTime()). Are you sure this is correct? If so, you might want to change this to $this->asDateTime().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
69
        }
70 5
71
        return new Timestamp($value->getTimestamp() * 1000);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return new \Cassandra\Ti...getTimestamp() * 1000); (Cassandra\Timestamp) is incompatible with the return type of the parent method Illuminate\Database\Eloquent\Model::fromDateTime of type integer|string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
72
    }
73 5
74 5
    /**
75
     * @inheritdoc
76
     */
77
    protected function asDateTime($value)
78
    {
79
        // Convert UTCDateTime instances.
80
        if ($value instanceof Timestamp) {
0 ignored issues
show
Bug introduced by
The class Cassandra\Timestamp does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
81
            return Carbon::instance($value->toDateTime());
82
        }
83
84
        return parent::asDateTime($value);
85
    }
86
87
    /**
88
     * @inheritdoc
89
     */
90
    protected function originalIsNumericallyEquivalent($key)
91
    {
92
        $current = $this->attributes[$key];
93
        $original = $this->original[$key];
94
95
        // Date comparison.
96
        if (in_array($key, $this->getDates())) {
97
            $current = $current instanceof Timestamp ? $this->asDateTime($current) : $current;
0 ignored issues
show
Bug introduced by
The class Cassandra\Timestamp does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
98
            $original = $original instanceof Timestamp ? $this->asDateTime($original) : $original;
0 ignored issues
show
Bug introduced by
The class Cassandra\Timestamp does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
99
100
            return $current == $original;
101
        }
102
103
        return parent::originalIsNumericallyEquivalent($key);
104
    }
105
106 8
    /**
107
     * Get the table qualified key name.
108 8
     * Cassandra does not support the table.column annotation so
109
     * we override this
110
     *
111
     * @return string
112
     */
113
    public function getQualifiedKeyName()
114
    {
115
        return $this->getKeyName();
116
    }
117 2
118
    /**
119 2
     * Qualify the given column name by the model's table.
120
     *
121
     * @param  string  $column
122
     * @return string
123
     */
124
    public function qualifyColumn($column)
125
    {
126
        return $column;
127
    }
128
129 12
     /**
130
     * Set a given attribute on the model.
131
     *
132
     * @param  string  $key
133
     * @param  mixed  $value
134 12
     * @return $this
135
     */
136
    public function setAttribute($key, $value)
137
    {
138
        // First we will check for the presence of a mutator for the set operation
139
        // which simply lets the developers tweak the attribute as it is set on
140
        // the model, such as "json_encoding" an listing of data for storage.
141
        if ($this->hasSetMutator($key)) {
142
            $method = 'set' . Str::studly($key) . 'Attribute';
143 12
144 12
            return $this->{$method}($value);
145
        }
146
147 12
        // If an attribute is listed as a "date", we'll convert it from a DateTime
148
        // instance into a form proper for storage on the database tables using
149
        // the connection grammar's date format. We will auto set the values.
150
        elseif ($value !== null && $this->isDateAttribute($key)) {
151
            $value = $this->fromDateTime($value);
152
        }
153
154 12
        if ($this->isJsonCastable($key) && !is_null($value)) {
155
            $value = $this->castAttributeAsJson($key, $value);
156
        }
157
158 12
        // If this attribute contains a JSON ->, we'll set the proper value in the
159
        // attribute's underlying array. This takes care of properly nesting an
160 12
        // attribute in the array's value in the case of deeply nested items.
161
        if (Str::contains($key, '->')) {
162
            return $this->fillJsonAttribute($key, $value);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->fillJsonAttribute($key, $value); (lroman242\LaravelCassandra\Eloquent\Model) is incompatible with the return type of the parent method Illuminate\Database\Eloquent\Model::setAttribute of type Illuminate\Database\Eloq...\Concerns\HasAttributes.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
163
        }
164
165
        $this->attributes[$key] = $value;
166 18
167
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this; (lroman242\LaravelCassandra\Eloquent\Model) is incompatible with the return type of the parent method Illuminate\Database\Eloquent\Model::setAttribute of type Illuminate\Database\Eloq...\Concerns\HasAttributes.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
168
    }
169 18
    
170
    /**
171
     * @inheritdoc
172
     */
173 18
    public function __call($method, $parameters)
174
    {
175
        // Unset method
176
        if ($method == 'unset') {
177
            return call_user_func_array([$this, 'drop'], $parameters);
178
        }
179
180
        return parent::__call($method, $parameters);
181
    }
182
183 13
    /**
184
     * Create a new Eloquent Collection instance.
185 13
     *
186
     * @param  Rows|array  $rows
187
     *
188
     * @return Collection
189
     *
190
     * @throws \Exception
191
     */
192
    public function newCassandraCollection($rows)
193
    {
194
        if (!is_array($rows) && !$rows instanceof \Cassandra\Rows) {
0 ignored issues
show
Bug introduced by
The class Cassandra\Rows does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
195 12
            throw new \Exception('Wrong type to create collection');//TODO: customize error
196
        }
197 12
198 12
        return new Collection($rows, $this);
199
    }
200
201 2
    /**
202
     * Determine if the new and old values for a given key are equivalent.
203 2
     *
204 2
     * @param  string $key
205 2
     * @param  mixed $current
206
     * @return bool
207 2
     */
208 2
    public function originalIsEquivalent($key, $current)
209 2
    {
210 1
        if (!array_key_exists($key, $this->original)) {
211
            return false;
212
        }
213 1
214
        $original = $this->getOriginal($key);
215
216
        if ($current === $original) {
217
            return true;
218 1
        } elseif (is_null($current)) {
219 1
            return false;
220
        } elseif ($this->isDateAttribute($key)) {
221
            return $this->fromDateTime($current) ===
222
                $this->fromDateTime($original);
223
        } elseif ($this->hasCast($key)) {
224
            return $this->castAttribute($key, $current) ===
225
                $this->castAttribute($key, $original);
226
        } elseif ($this->isCassandraObject($current)) {
227
            return $this->valueFromCassandraObject($current) ===
228 1
                $this->valueFromCassandraObject($original);
229
        }
230 1
231 1
        return is_numeric($current) && is_numeric($original)
232 1
            && strcmp((string) $current, (string) $original) === 0;
233 1
    }
234 1
235 1
    /**
236 1
     * Check if object is instance of any cassandra object types
237
     *
238
     * @param $obj
239
     * @return bool
240 1
     */
241
    protected function isCassandraObject($obj)
242
    {
243
        if ($obj instanceof \Cassandra\Uuid ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Uuid does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
244
            $obj instanceof \Cassandra\Date ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Date does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
245
            $obj instanceof \Cassandra\Float ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Float does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
246
            $obj instanceof \Cassandra\Decimal ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Decimal does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
247
            $obj instanceof \Cassandra\Timestamp ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Timestamp does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
248
            $obj instanceof \Cassandra\Inet ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Inet does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
249
            $obj instanceof \Cassandra\Time
0 ignored issues
show
Bug introduced by
The class Cassandra\Time does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
250
        ) {
251
            return true;
252
        } else {
253
            return false;
254
        }
255
    }
256
257
    /**
258
     * Check if object is instance of any cassandra object types
259
     *
260
     * @param $obj
261
     * @return bool
262
     */
263
    protected function isCompareableCassandraObject($obj)
264
    {
265
        if ($obj instanceof \Cassandra\Uuid ||
0 ignored issues
show
Bug introduced by
The class Cassandra\Uuid does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
266
            $obj instanceof \Cassandra\Inet
0 ignored issues
show
Bug introduced by
The class Cassandra\Inet does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
267
        ) {
268
            return true;
269
        } else {
270
            return false;
271
        }
272
    }
273
274
    /**
275
     * Returns comparable value from cassandra object type
276
     *
277
     * @param $obj
278
     * @return mixed
279
     */
280
    protected function valueFromCassandraObject($obj)
281
    {
282
        $class = get_class($obj);
283
        $value = '';
284
        switch ($class) {
285
            case 'Cassandra\Date':
286
                $value = $obj->seconds();
287
                break;
288
            case 'Cassandra\Time':
289
                $value = $obj->__toString();
290
                break;
291
            case 'Cassandra\Timestamp':
292
                $value = $obj->time();
293
                break;
294
            case 'Cassandra\Float':
295
                $value = $obj->value();
296
                break;
297
            case 'Cassandra\Decimal':
298
                $value = $obj->value();
299
                break;
300
            case 'Cassandra\Inet':
301
                $value = $obj->address();
302
                break;
303
            case 'Cassandra\Uuid':
304
                $value = $obj->uuid();
305
                break;
306
        }
307
308
        return $value;
309
    }
310
311
}
312